Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH 2/2] scsi: set timed out out mq requests to complete
Date: Thu, 19 Jul 2018 15:26:18 -0600	[thread overview]
Message-ID: <20180719212618.2406-2-keith.busch@intel.com> (raw)
In-Reply-To: <20180719212618.2406-1-keith.busch@intel.com>

The scsi block layer requires requests claimed be the error handling be
completed by the error handler. A previous commit allowed completions
to proceed for blk-mq, breaking that assumption.

This patch prevents completions that may race with the timeout handler
by marking the state to complete, restoring the previous behavior.

Fixes: 12f5b931 ("blk-mq: Remove generation seqeunce")
Signed-off-by: Keith Busch <keith.busch at intel.com>
---

Tested using Jianchao's abort injection to scsi_debug described here:

  https://lore.kernel.org/lkml/a68ad043-26a1-d3d8-2009-504ba4230e0f at oracle.com/

 drivers/scsi/scsi_error.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 8932ae81a15a..86ee10b2c775 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -286,6 +286,9 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
 	enum blk_eh_timer_return rtn = BLK_EH_DONE;
 	struct Scsi_Host *host = scmd->device->host;
 
+	if (req->q->mq_ops && blk_mq_mark_complete(req))
+		return rtn;
+
 	trace_scsi_dispatch_cmd_timeout(scmd);
 	scsi_log_completion(scmd, TIMEOUT_ERROR);
 
@@ -300,7 +303,8 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
 			set_host_byte(scmd, DID_TIME_OUT);
 			scsi_eh_scmd_add(scmd);
 		}
-	}
+	} else if (req->q->mq_ops)
+		WRITE_ONCE(req->state, MQ_RQ_IN_FLIGHT);
 
 	return rtn;
 }
-- 
2.14.4

  reply	other threads:[~2018-07-19 21:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-19 21:26 [PATCH 1/2] blk-mq: export setting request completion state Keith Busch
2018-07-19 21:26 ` Keith Busch [this message]
2018-07-20  6:52   ` [PATCH 2/2] scsi: set timed out out mq requests to complete Johannes Thumshirn
2018-07-20 14:05     ` Keith Busch
2018-07-20 14:41   ` Christoph Hellwig
2018-07-20 14:50     ` Keith Busch
2018-07-20 15:12   ` Bart Van Assche
2018-07-20 15:56     ` Keith Busch
2018-07-20 16:03       ` Bart Van Assche
2018-07-20 16:12         ` Keith Busch
2018-07-20 16:20           ` Bart Van Assche
2018-07-20 16:23             ` Keith Busch
2018-07-20 16:45               ` Bart Van Assche
2018-07-20 17:24                 ` Keith Busch
2018-07-23  8:12                   ` hch
2018-07-23 13:59                     ` Bart Van Assche
2018-07-23 14:04                     ` Keith Busch
2018-07-23  8:09 ` [PATCH 1/2] blk-mq: export setting request completion state Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180719212618.2406-2-keith.busch@intel.com \
    --to=keith.busch@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox