mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com>
To: James Bottomley <JBottomley@parallels.com>,
	Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@fb.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ming Lei <ming.lei@canonical.com>
Subject: [PATCH] scsi-mq: fix hw queue hang caused by timeout
Date: Thu, 18 Sep 2014 23:59:10 +0800	[thread overview]
Message-ID: <1411055950-28657-1-git-send-email-ming.lei@canonical.com> (raw)

If there are two requests or more timed out, the dispatch queue
is put into stopped state and never be recoverd, and there
is no such problem in non-mq mode.

This patch trys to recover the stopped queue when the queue
becomes unbusy, then the following retries can move on.

Basically this patch maintains same behavior for this situation
with non-mq mode.

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/scsi/scsi_lib.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 3b92c39..dfbc028 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -142,6 +142,8 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
 	struct scsi_device *device = cmd->device;
 	struct request_queue *q = device->request_queue;
 	unsigned long flags;
+	bool restart = false;
+	bool blocked = !!atomic_read(&device->device_blocked);
 
 	SCSI_LOG_MLQUEUE(1, scmd_printk(KERN_INFO, cmd,
 		"Inserting command %p into mlqueue\n", cmd));
@@ -152,9 +154,14 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
 	 * Decrement the counters, since these commands are no longer
 	 * active on the host/device.
 	 */
-	if (unbusy)
+	if (unbusy) {
 		scsi_device_unbusy(device);
 
+		/* need to restart hw queue if it was stopped */
+		if (!atomic_read(&device->device_busy) && blocked)
+			restart = true;
+	}
+
 	/*
 	 * Requeue this command.  It will go before all other commands
 	 * that are already in the queue. Schedule requeue work under
@@ -164,6 +171,8 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
 	cmd->result = 0;
 	if (q->mq_ops) {
 		scsi_mq_requeue_cmd(cmd);
+		if (restart)
+			blk_mq_start_stopped_hw_queues(q, true);
 		return;
 	}
 	spin_lock_irqsave(q->queue_lock, flags);
-- 
1.7.9.5


             reply	other threads:[~2014-09-18 15:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18 15:59 Ming Lei [this message]
2014-09-18 16:35 ` Christoph Hellwig
2014-09-18 17:03   ` Jens Axboe
2014-09-19 13:07     ` Ming Lei
2014-09-19 14:18       ` Ming Lei
2014-09-19 14:21         ` Jens Axboe

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=1411055950-28657-1-git-send-email-ming.lei@canonical.com \
    --to=ming.lei@canonical.com \
    --cc=JBottomley@parallels.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®