linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SCSI: delay run queue if device is blocked in scsi_dev_queue_ready()
@ 2017-12-02 16:31 Ming Lei
  2017-12-04  8:19 ` Johannes Thumshirn
  2017-12-04 15:09 ` Bart Van Assche
  0 siblings, 2 replies; 11+ messages in thread
From: Ming Lei @ 2017-12-02 16:31 UTC (permalink / raw)
  To: Jens Axboe, linux-block, Christoph Hellwig, linux-scsi,
	Martin K . Petersen, James E . J . Bottomley
  Cc: Bart Van Assche, linux-kernel, Hannes Reinecke, Ming Lei

Before commit 0df21c86bdbf ("scsi: implement .get_budget and .put_budget
for blk-mq"), we run queue after 3ms if device is blocked and queue is
idle, which is done in handling BLK_STS_RESOURCE. After commit 0df21c86bdbf
is introduced, queue won't be run any more under this situation.

IO hang is observed when timeout happened, and this patch fixes the IO
hang issue by running queue after delay in scsi_dev_queue_ready, just like
non-mq.

This issue can be triggered by the following script:

	#!/bin/sh
	rmmod scsi_debug
	modprobe scsi_debug max_queue=1

	DEVICE=`ls -d /sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*/block/* | head -1 | xargs basename`

	DISK_DIR=`ls -d /sys/block/$DEVICE/device/scsi_disk/*`

	echo "using scsi device $DEVICE"
	echo "-1" >/sys/bus/pseudo/drivers/scsi_debug/every_nth
	echo starting loop $i
	echo "temporary write through" >$DISK_DIR/cache_type
	echo "128" >/sys/bus/pseudo/drivers/scsi_debug/opts
	echo none > /sys/block/$DEVICE/queue/scheduler
	dd if=/dev/$DEVICE of=/dev/null bs=1M iflag=direct count=1 &
	sleep 5
	echo "0" >/sys/bus/pseudo/drivers/scsi_debug/opts
	wait
	echo "SUCCESS"

Fixes: 0df21c86bdbf ("scsi: implement .get_budget and .put_budget for blk-mq")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/scsi/scsi_lib.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index cf9f36a1113f..9aada86055d3 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1387,6 +1387,15 @@ static void scsi_unprep_fn(struct request_queue *q, struct request *req)
 	scsi_uninit_cmd(blk_mq_rq_to_pdu(req));
 }
 
+static void scsi_mq_delay_queue(struct request_queue *q, unsigned long msecs)
+{
+	struct blk_mq_hw_ctx *hctx;
+	int i;
+
+	queue_for_each_hw_ctx(q, hctx, i)
+		blk_mq_delay_run_hw_queue(hctx, msecs);
+}
+
 /*
  * scsi_dev_queue_ready: if we can send requests to sdev, return 1 else
  * return 0.
@@ -1407,11 +1416,10 @@ static inline int scsi_dev_queue_ready(struct request_queue *q,
 		 * unblock after device_blocked iterates to zero
 		 */
 		if (atomic_dec_return(&sdev->device_blocked) > 0) {
-			/*
-			 * For the MQ case we take care of this in the caller.
-			 */
 			if (!q->mq_ops)
 				blk_delay_queue(q, SCSI_QUEUE_DELAY);
+			else
+				scsi_mq_delay_queue(q, SCSI_QUEUE_DELAY);
 			goto out_dec;
 		}
 		SCSI_LOG_MLQUEUE(3, sdev_printk(KERN_INFO, sdev,
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-12-05 11:35 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-02 16:31 [PATCH] SCSI: delay run queue if device is blocked in scsi_dev_queue_ready() Ming Lei
2017-12-04  8:19 ` Johannes Thumshirn
2017-12-04  8:34   ` Ming Lei
2017-12-04  8:44     ` Johannes Thumshirn
2017-12-04  8:58       ` Ming Lei
2017-12-04 15:09 ` Bart Van Assche
2017-12-04 22:45   ` Ming Lei
2017-12-04 22:49     ` Bart Van Assche
     [not found]     ` <pan$2c3c7$7c7c04a5$f22df3ad$bef841cb@applied-asynchrony.com>
2017-12-05  5:16       ` Ming Lei
2017-12-05  6:56         ` Ming Lei
2017-12-05 11:26         ` Holger Hoffstätte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).