From: Christoph Hellwig <hch@infradead.org>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>, Jeff Moyer <jmoyer@redhat.com>,
Jens Axboe <axboe@kernel.dk>, Shaohua Li <shli@fusionio.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] block: rework flush sequencing for blk-mq
Date: Fri, 14 Mar 2014 02:34:58 -0700 [thread overview]
Message-ID: <20140314093458.GA19451@infradead.org> (raw)
In-Reply-To: <20140314092519.GA10139@infradead.org>
On Fri, Mar 14, 2014 at 02:25:19AM -0700, Christoph Hellwig wrote:
> b) is a bit harder, but we should think hard about it when rewriting the
> multipath code to support blk-mq. Talking about which I think trying to
> use dm-multipath on any blk-mq device will go horribly crash and boom at
> the moment.
Talking abnout crashing and burning.. Hannes, did you run this patch
past dm-devel and linux-scsi yet? Don't quite like it but the problem
seems real..
From: Hannes Reinecke <hare@suse.de>
Subject: Kernel bug triggered in multipath
References: bnc#486001
Patch-mainline: not yet
Starting multipath on a cciss device will cause a kernel
warning to be triggered. Problem is that we're using the
->queuedata field of the request_queue to derefence the
scsi device; however, for other (non-SCSI) devices this
points to a totally different structure.
So we should rather be using accessors here which make
sure we're only returning valid SCSI device structures.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/scsi/device_handler/scsi_dh.c | 10 +++++-----
drivers/scsi/scsi_lib.c | 11 +++++++++++
include/scsi/scsi_device.h | 1 +
3 files changed, 17 insertions(+), 5 deletions(-)
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -397,7 +397,7 @@ int scsi_dh_activate(struct request_queu
struct device *dev = NULL;
spin_lock_irqsave(q->queue_lock, flags);
- sdev = q->queuedata;
+ sdev = scsi_device_from_queue(q);
if (!sdev) {
spin_unlock_irqrestore(q->queue_lock, flags);
err = SCSI_DH_NOSYS;
@@ -484,7 +484,7 @@ int scsi_dh_attach(struct request_queue
return -EINVAL;
spin_lock_irqsave(q->queue_lock, flags);
- sdev = q->queuedata;
+ sdev = scsi_device_from_queue(q);
if (!sdev || !get_device(&sdev->sdev_gendev))
err = -ENODEV;
spin_unlock_irqrestore(q->queue_lock, flags);
@@ -512,7 +512,7 @@ void scsi_dh_detach(struct request_queue
struct scsi_device_handler *scsi_dh = NULL;
spin_lock_irqsave(q->queue_lock, flags);
- sdev = q->queuedata;
+ sdev = scsi_device_from_queue(q);
if (!sdev || !get_device(&sdev->sdev_gendev))
sdev = NULL;
spin_unlock_irqrestore(q->queue_lock, flags);
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1594,6 +1594,17 @@ out:
spin_lock_irq(q->queue_lock);
}
+struct scsi_device *scsi_device_from_queue(struct request_queue *q)
+{
+ struct scsi_device *sdev = NULL;
+
+ if (q->request_fn == scsi_request_fn)
+ sdev = q->queuedata;
+
+ return sdev;
+}
+EXPORT_SYMBOL_GPL(scsi_device_from_queue);
+
u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
{
struct device *host_dev;
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -300,6 +300,7 @@ extern void starget_for_each_device(stru
extern void __starget_for_each_device(struct scsi_target *, void *,
void (*fn)(struct scsi_device *,
void *));
+extern struct scsi_device *scsi_device_from_queue(struct request_queue *);
/* only exposed to implement shost_for_each_device */
extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
next prev parent reply other threads:[~2014-03-14 9:35 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-30 13:26 [PATCH 0/1] block: rework flush sequencing for blk-mq Christoph Hellwig
2014-01-30 13:26 ` [PATCH 1/1] " Christoph Hellwig
2014-02-07 1:18 ` Shaohua Li
2014-02-07 14:19 ` Christoph Hellwig
2014-02-08 0:55 ` Shaohua Li
2014-02-10 10:33 ` Christoph Hellwig
2014-03-07 20:45 ` Jeff Moyer
2014-03-08 15:52 ` Christoph Hellwig
2014-03-08 17:33 ` Mike Snitzer
2014-03-08 19:51 ` Hannes Reinecke
2014-03-08 18:13 ` Mike Snitzer
2014-03-08 21:33 ` Hannes Reinecke
2014-03-08 22:09 ` [PATCH] block: fix q->flush_rq NULL pointer crash on dm-mpath flush Mike Snitzer
2014-03-09 0:24 ` Jens Axboe
2014-03-09 0:57 ` Mike Snitzer
2014-03-09 3:18 ` Jens Axboe
2014-03-09 3:29 ` Mike Snitzer
2014-03-12 10:28 ` [PATCH 1/1] block: rework flush sequencing for blk-mq Christoph Hellwig
2014-03-12 10:50 ` Hannes Reinecke
2014-03-12 10:55 ` Christoph Hellwig
2014-03-12 11:07 ` Hannes Reinecke
[not found] ` <53203BE5.402-l3A5Bk7waGM@public.gmane.org>
2014-03-12 11:00 ` SuSE O_DIRECT|O_NONBLOCK overload Christoph Hellwig
2014-03-12 11:00 ` Christoph Hellwig
[not found] ` <20140312110015.GA29907-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-03-13 0:15 ` NeilBrown
2014-03-13 0:15 ` NeilBrown
[not found] ` <20140313111555.2f15f19f-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2014-03-14 17:46 ` Mike Christie
2014-03-14 17:46 ` Mike Christie
2014-03-13 16:13 ` [PATCH 1/1] block: rework flush sequencing for blk-mq Mike Snitzer
2014-03-14 9:25 ` Christoph Hellwig
2014-03-14 9:30 ` Hannes Reinecke
2014-03-14 12:44 ` Christoph Hellwig
2014-03-14 9:34 ` Christoph Hellwig [this message]
2014-03-14 9:52 ` Hannes Reinecke
2014-03-14 10:58 ` Christoph Hellwig
2014-03-14 11:10 ` Hannes Reinecke
2014-03-14 13:00 ` Mike Snitzer
2014-03-14 13:23 ` Christoph Hellwig
2014-03-14 14:13 ` Mike Snitzer
2014-03-15 13:28 ` scsi_debug and mutipath, was " Christoph Hellwig
2014-03-17 11:55 ` [dm-devel] " Bryn M. Reeves
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=20140314093458.GA19451@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=jmoyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shli@fusionio.com \
--cc=snitzer@redhat.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 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.