All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Mike Snitzer <snitzer@redhat.com>,
	Roland Dreier <roland@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Alan Stern <stern@rowland.harvard.edu>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux-scsi@vger.kernel.org,
	Steffen Maier <maier@linux.vnet.ibm.com>,
	"Manvanthara B. Puttashankar" <manvanth@linux.vnet.ibm.com>,
	Tarak Reddy <tarak.reddy@in.ibm.com>,
	"Seshagiri N. Ippili" <sesh17@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org,
	device-mapper development <dm-devel@redhat.com>,
	Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH] block: Check that queue is alive in blk_insert_cloned_request()
Date: Tue, 12 Jul 2011 14:02:38 -0400	[thread overview]
Message-ID: <20110712180238.GJ1293@redhat.com> (raw)
In-Reply-To: <1310492490.16900.20.camel@mulgrave>

On Tue, Jul 12, 2011 at 12:41:30PM -0500, James Bottomley wrote:
> On Tue, 2011-07-12 at 13:06 -0400, Vivek Goyal wrote:
> > On Mon, Jul 11, 2011 at 06:40:11PM -0400, Mike Snitzer wrote:
> > > [cc'ing dm-devel, vivek and tejun]
> > > 
> > > On Fri, Jul 8, 2011 at 7:04 PM, Roland Dreier <roland@kernel.org> wrote:
> > > > From: Roland Dreier <roland@purestorage.com>
> > > >
> > > > This fixes crashes such as the below that I see when the storage
> > > > underlying a dm-multipath device is hot-removed.  The problem is that
> > > > dm requeues a request to a device whose block queue has already been
> > > > cleaned up, and blk_insert_cloned_request() doesn't check if the queue
> > > > is alive, but rather goes ahead and tries to queue the request.  This
> > > > ends up dereferencing the elevator that was already freed in
> > > > blk_cleanup_queue().
> > > 
> > > Your patch looks fine to me:
> > > Acked-by: Mike Snitzer <snitzer@redhat.com>
> > > 
> > > And I looked at various code paths to arrive at the references DM takes.
> > > 
> > > A reference is taken on the underlying devices' block_device via
> > > drivers/md/dm-table.c:open_dev() with blkdev_get_by_dev().  open_dev()
> > > also does bd_link_disk_holder(), resulting in the mpath device
> > > becoming a holder of the underlying devices. e.g.:
> > > /sys/block/sda/holders/dm-4
> > > 
> > > But at no point does DM-mpath get a reference to the underlying
> > > devices' request_queue that gets assigned to clone->q (in
> > > drivers/md/dm-mpath.c:map_io).
> > > 
> > > Seems we should, though AFAIK it won't help with the issue you've
> > > pointed out (because the hotplugged device's driver already called
> > > blk_cleanup_queue and nuked the elevator).
> > 
> > [Thinking loud]
> > 
> > Could it be a driver specific issue that it cleaned up the request
> > queue too early?
> 
> One could glibly answer yes to this.  However, the fact is that it's
> currently SCSI which manages the queue, so SCSI cleans it up.  Now, the
> only real thing dm is interested in is the queue itself, hence the need
> to take a reference to the queue.  However, queue references don't pin
> SCSI devices, so you can hold a queue reference all you like and SCSI
> will still clean up the queue.
> 
> I think a better question is what should cleaning up the queue do?  SCSI
> uses it to indicate that we're no longer processing requests, which
> happens when the device goes into a DEL state, but queue cleanup tears
> down the elevators and really makes the request queue non functional.
> In this case, holding a reference isn't particularly helpful.
> 
> I'm starting to wonder if there's actually any value to
> blk_cleanup_queue() and whether its functionality wouldn't be better
> assumed by the queue release function on last put.

I think one problem point is q->queue_lock. If driver drops its reference
on queue and cleans up its data structures, then it will free up memory
associated with q->queue_lock too. (If driver provided its own queue
lock). In that case anything which is dependent on queue lock, needs
to be freed up on blk_cleanup_queue().

If we can make sure that request queue reference will keep the spin lock
alive, then i guess all cleanup part might be able to go in release
queue function.

Thanks
Vivek

  reply	other threads:[~2011-07-12 18:02 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15 11:20 [BUG] 2.6.39.1 crash in scsi_dispatch_cmd() Heiko Carstens
2011-06-16 16:01 ` Heiko Carstens
2011-06-16 16:37   ` James Bottomley
2011-06-16 18:40     ` Heiko Carstens
2011-06-20 15:30       ` Heiko Carstens
2011-07-01 18:07         ` Roland Dreier
2011-07-01 19:04           ` James Bottomley
2011-07-06  0:34             ` Roland Dreier
2011-07-06  6:47               ` Heiko Carstens
2011-07-06  8:06                 ` Roland Dreier
2011-07-06  9:25                   ` Heiko Carstens
2011-07-06 14:20                   ` Alan Stern
2011-07-06 14:24                     ` James Bottomley
2011-07-06 16:30                       ` Roland Dreier
2011-07-06 16:53                         ` Alan Stern
2011-07-06 18:07                           ` Roland Dreier
2011-07-06 18:49                             ` Alan Stern
2011-07-07 20:45                               ` James Bottomley
2011-07-07 21:07                                 ` Alan Stern
2011-07-08 17:04                                   ` James Bottomley
2011-07-08 19:43                                     ` Alan Stern
2011-07-08 20:41                                       ` James Bottomley
2011-07-08 22:08                                         ` Alan Stern
2011-07-08 22:25                                           ` James Bottomley
2011-07-08 20:47                                     ` Roland Dreier
2011-07-08 23:04                                       ` [PATCH] block: Check that queue is alive in blk_insert_cloned_request() Roland Dreier
2011-07-09  9:05                                         ` Stefan Richter
2011-07-11 22:40                                         ` Mike Snitzer
2011-07-12  0:52                                           ` Alan Stern
2011-07-12  0:52                                             ` Alan Stern
2011-07-12  1:22                                             ` Mike Snitzer
2011-07-12  1:46                                               ` Vivek Goyal
2011-07-12 15:24                                                 ` Alan Stern
2011-07-12 15:24                                                   ` Alan Stern
2011-07-12 17:10                                                   ` Vivek Goyal
2011-07-12 14:58                                           ` [PATCH] dm mpath: manage reference on request queue of underlying devices Mike Snitzer
2011-07-12 17:06                                           ` [PATCH] block: Check that queue is alive in blk_insert_cloned_request() Vivek Goyal
2011-07-12 17:41                                             ` James Bottomley
2011-07-12 18:02                                               ` Vivek Goyal [this message]
2011-07-12 18:28                                                 ` James Bottomley
2011-07-12 18:54                                                   ` Vivek Goyal
2011-07-12 18:54                                                     ` Vivek Goyal
2011-07-12 21:02                                                   ` Alan Stern
2011-07-12 21:02                                                     ` Alan Stern
2011-07-12  2:09                                         ` Vivek Goyal
2011-07-06 16:24                     ` [BUG] 2.6.39.1 crash in scsi_dispatch_cmd() Roland Dreier

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=20110712180238.GJ1293@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=maier@linux.vnet.ibm.com \
    --cc=manvanth@linux.vnet.ibm.com \
    --cc=roland@kernel.org \
    --cc=sesh17@linux.vnet.ibm.com \
    --cc=snitzer@redhat.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tarak.reddy@in.ibm.com \
    --cc=tj@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.