From: Elias Oltmanns <eo@nebensachen.de>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: linux-scsi@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH] SCSI: Fix some locking issues
Date: Tue, 01 Jul 2008 23:37:35 +0200 [thread overview]
Message-ID: <87prpxnv4w.fsf@denkblock.local> (raw)
In-Reply-To: <877ic8o4iq.fsf@denkblock.local> (Elias Oltmanns's message of "Sun, 29 Jun 2008 13:38:05 +0200")
Hi James,
sorry for bothering you but I've just noticed that the patch below has
neither been scheduled for the stable review, nor queued up for Linus.
May be you just don't consider this serious enough for these trees but I
wanted to make sure that the situation will be dealt with eventualy. The
patch applies to 2.6.26-rc8.
Regards,
Elias
From: Elias Oltmanns <eo@nebensachen.de>
Subject: SCSI: Fix some locking issues
Make sure that host_blocked is consistently protected by the host_lock.
Similarly, device_block has to be protected by the queue_lock. Also,
blk_plug_device() has to be called with the queue_lock held in
scsi_host_queue_ready().
Cc: stable@kernel.org
Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
---
drivers/scsi/scsi.c | 6 ++++++
drivers/scsi/scsi_lib.c | 13 +++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 110e776..b8b7982 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -826,8 +826,10 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
{
struct scsi_device *sdev = cmd->device;
struct Scsi_Host *shost = sdev->host;
+ struct request_queue *q = sdev->request_queue;
struct scsi_driver *drv;
unsigned int good_bytes;
+ unsigned long flags;
scsi_device_unbusy(sdev);
@@ -839,8 +841,12 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
*
* XXX(hch): What about locking?
*/
+ spin_lock_irqsave(shost->host_lock, flags);
shost->host_blocked = 0;
+ spin_unlock(shost->host_lock);
+ spin_lock(q->queue_lock);
sdev->device_blocked = 0;
+ spin_unlock_irqrestore(q->queue_lock, flags);
/*
* If we have valid sense information, then some kind of recovery
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index a82d2fe..65d0c39 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -133,10 +133,15 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
* if a command is requeued with no other commands outstanding
* either for the device or for the host.
*/
- if (reason == SCSI_MLQUEUE_HOST_BUSY)
+ if (reason == SCSI_MLQUEUE_HOST_BUSY) {
+ spin_lock_irqsave(host->host_lock, flags);
host->host_blocked = host->max_host_blocked;
- else if (reason == SCSI_MLQUEUE_DEVICE_BUSY)
+ spin_unlock_irqrestore(host->host_lock, flags);
+ } else if (reason == SCSI_MLQUEUE_DEVICE_BUSY) {
+ spin_lock_irqsave(q->queue_lock, flags);
device->device_blocked = device->max_device_blocked;
+ spin_unlock_irqrestore(q->queue_lock, flags);
+ }
/*
* Decrement the counters, since these commands are no longer
@@ -1320,7 +1325,11 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
printk("scsi%d unblocking host at zero depth\n",
shost->host_no));
} else {
+ spin_unlock(shost->host_lock);
+ spin_lock(q->queue_lock);
blk_plug_device(q);
+ spin_unlock(q->queue_lock);
+ spin_lock(shost->host_lock);
return 0;
}
}
next prev parent reply other threads:[~2008-07-01 21:38 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-29 11:38 [PATCH] SCSI: Fix some locking issues Elias Oltmanns
2008-07-01 21:37 ` Elias Oltmanns [this message]
2008-07-02 1:55 ` James Bottomley
2008-07-02 7:08 ` Elias Oltmanns
2008-07-02 11:50 ` Jens Axboe
2008-07-02 14:49 ` James Bottomley
2008-07-02 18:45 ` Jens Axboe
2008-07-02 20:18 ` James Bottomley
2008-07-03 7:53 ` Elias Oltmanns
2008-07-03 10:38 ` Elias Oltmanns
2008-07-03 11:24 ` Jens Axboe
2008-07-03 16:31 ` James Bottomley
2008-07-03 17:54 ` Jens Axboe
2008-07-03 19:47 ` Elias Oltmanns
2008-07-03 21:33 ` James Bottomley
2008-07-02 14:46 ` James Bottomley
2008-07-02 15:59 ` Elias Oltmanns
2008-07-02 16:23 ` Matthew Wilcox
2008-07-03 7:12 ` Elias Oltmanns
2008-07-03 15:22 ` James Bottomley
2008-07-03 19:39 ` Elias Oltmanns
2008-07-03 15:47 ` Matthew Wilcox
2008-07-02 16:32 ` James Bottomley
2008-07-03 7:25 ` 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=87prpxnv4w.fsf@denkblock.local \
--to=eo@nebensachen.de \
--cc=James.Bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=stable@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;
as well as URLs for NNTP newsgroup(s).