All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elias Oltmanns <eo@nebensachen.de>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org, Tejun Heo <htejun@gmail.com>
Subject: [PATCH] Make sure that scsi_request_fn() isn't called recursively forever
Date: Sun, 10 Feb 2008 14:02:32 +0100	[thread overview]
Message-ID: <878x1tnevr.fsf_-_@denkblock.local> (raw)
In-Reply-To: <87ejblnf94.fsf@denkblock.local> (Elias Oltmanns's message of "Sun, 10 Feb 2008 13:54:31 +0100")

Currently, scsi_dev_queue_ready() and scsi_host_queue_ready() decrease the
device_blocked or host_blocked counter respectively *before* they determine
the right return value. If the device can't accept a request for some
reason and max_host_blocked or max_device_blocked has been set to 1, this
may lead to scsi_request_fn() being called recursively without giving the
low level driver a chance to unjam the device.

This patch applies to 2.6.24. Please include it in the stable updates as
well.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
---

 drivers/scsi/scsi_lib.c |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index a9ac5b1..7513bed 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1357,14 +1357,12 @@ static inline int scsi_dev_queue_ready(s
 		/*
 		 * unblock after device_blocked iterates to zero
 		 */
-		if (--sdev->device_blocked == 0) {
+		if (sdev->device_blocked-- == 1)
 			SCSI_LOG_MLQUEUE(3,
 				   sdev_printk(KERN_INFO, sdev,
-				   "unblocking device at zero depth\n"));
-		} else {
-			blk_plug_device(q);
-			return 0;
-		}
+				   "device will be unblocked next time\n"));
+		blk_plug_device(q);
+		return 0;
 	}
 	if (sdev->device_blocked)
 		return 0;
@@ -1389,14 +1387,12 @@ static inline int scsi_host_queue_ready(
 		/*
 		 * unblock after host_blocked iterates to zero
 		 */
-		if (--shost->host_blocked == 0) {
+		if (shost->host_blocked-- == 1)
 			SCSI_LOG_MLQUEUE(3,
-				printk("scsi%d unblocking host at zero depth\n",
+				printk("scsi%d host will be unblocked next time\n",
 					shost->host_no));
-		} else {
-			blk_plug_device(q);
-			return 0;
-		}
+		blk_plug_device(q);
+		return 0;
 	}
 	if ((shost->can_queue > 0 && shost->host_busy >= shost->can_queue) ||
 	    shost->host_blocked || shost->host_self_blocked) {

  reply	other threads:[~2008-02-10 13:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-09 21:59 Investigating potential flaw in scsi error handling Elias Oltmanns
2008-02-09 23:30 ` James Bottomley
2008-02-10 12:54   ` Elias Oltmanns
2008-02-10 13:02     ` Elias Oltmanns [this message]
2008-02-10 14:22     ` James Bottomley
2008-02-10 15:29       ` Elias Oltmanns
2008-02-10 15:44         ` James Bottomley
2008-02-10 16:04           ` Elias Oltmanns

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=878x1tnevr.fsf_-_@denkblock.local \
    --to=eo@nebensachen.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=htejun@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.