All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <keith.busch@intel.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
	Sagi Grimberg <sagi@grimberg.me>,
	linux-nvme@lists.infradead.org, Zhang Yi <yizhan@redhat.com>,
	linux-block@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] nvme: avoid to hang in remove disk
Date: Thu, 18 May 2017 12:06:24 -0400	[thread overview]
Message-ID: <20170518160624.GA6015@localhost.localdomain> (raw)
In-Reply-To: <20170518153542.GC18526@ming.t460p>

On Thu, May 18, 2017 at 11:35:43PM +0800, Ming Lei wrote:
> On Thu, May 18, 2017 at 03:49:31PM +0200, Christoph Hellwig wrote:
> > On Wed, May 17, 2017 at 09:27:29AM +0800, Ming Lei wrote:
> > > If some writeback requests are submitted just before queue is killed,
> > > and these requests may not be canceled in nvme_dev_disable() because
> > > they are not started yet, it is still possible for blk-mq to hold
> > > these requests in .requeue list.
> > > 
> > > So we have to abort these requests first before del_gendisk(), because
> > > del_gendisk() may wait for completion of these requests.
> > > 
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Ming Lei <ming.lei@redhat.com>
> > > ---
> > >  drivers/nvme/host/core.c | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > > 
> > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> > > index d5e0906262ea..8eaeea86509a 100644
> > > --- a/drivers/nvme/host/core.c
> > > +++ b/drivers/nvme/host/core.c
> > > @@ -2097,6 +2097,14 @@ static void nvme_ns_remove(struct nvme_ns *ns)
> > >  					&nvme_ns_attr_group);
> > >  		if (ns->ndev)
> > >  			nvme_nvm_unregister_sysfs(ns);
> > > +		/*
> > > +		 * If queue is dead, we have to abort requests in
> > > +		 * requeue list because fsync_bdev() in removing disk
> > > +		 * path may wait for these IOs, which can't
> > > +		 * be submitted to hardware too.
> > > +		 */
> > > +		if (blk_queue_dying(ns->queue))
> > > +			blk_mq_abort_requeue_list(ns->queue);
> > >  		del_gendisk(ns->disk);
> > >  		blk_mq_abort_requeue_list(ns->queue);
> > 
> > Why can't we just move the blk_mq_abort_requeue_list call before
> > del_gendisk in general?
> 
> That may cause data loss if queue isn't killed. Normally queue is only killed
> when the controller is dead(such as in reset failure) or !pci_device_is_present()
> (in nvme_remove()).

But in your test, your controller isn't even dead. Why are we killing
it when it's still functional? I think we need to first not consider
this perfectly functional controller to be dead under these conditions,
and second, understand why killing the queues after del_gendisk is called
does not allow forward progress.

WARNING: multiple messages have this Message-ID (diff)
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH 2/2] nvme: avoid to hang in remove disk
Date: Thu, 18 May 2017 12:06:24 -0400	[thread overview]
Message-ID: <20170518160624.GA6015@localhost.localdomain> (raw)
In-Reply-To: <20170518153542.GC18526@ming.t460p>

On Thu, May 18, 2017@11:35:43PM +0800, Ming Lei wrote:
> On Thu, May 18, 2017@03:49:31PM +0200, Christoph Hellwig wrote:
> > On Wed, May 17, 2017@09:27:29AM +0800, Ming Lei wrote:
> > > If some writeback requests are submitted just before queue is killed,
> > > and these requests may not be canceled in nvme_dev_disable() because
> > > they are not started yet, it is still possible for blk-mq to hold
> > > these requests in .requeue list.
> > > 
> > > So we have to abort these requests first before del_gendisk(), because
> > > del_gendisk() may wait for completion of these requests.
> > > 
> > > Cc: stable at vger.kernel.org
> > > Signed-off-by: Ming Lei <ming.lei at redhat.com>
> > > ---
> > >  drivers/nvme/host/core.c | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > > 
> > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> > > index d5e0906262ea..8eaeea86509a 100644
> > > --- a/drivers/nvme/host/core.c
> > > +++ b/drivers/nvme/host/core.c
> > > @@ -2097,6 +2097,14 @@ static void nvme_ns_remove(struct nvme_ns *ns)
> > >  					&nvme_ns_attr_group);
> > >  		if (ns->ndev)
> > >  			nvme_nvm_unregister_sysfs(ns);
> > > +		/*
> > > +		 * If queue is dead, we have to abort requests in
> > > +		 * requeue list because fsync_bdev() in removing disk
> > > +		 * path may wait for these IOs, which can't
> > > +		 * be submitted to hardware too.
> > > +		 */
> > > +		if (blk_queue_dying(ns->queue))
> > > +			blk_mq_abort_requeue_list(ns->queue);
> > >  		del_gendisk(ns->disk);
> > >  		blk_mq_abort_requeue_list(ns->queue);
> > 
> > Why can't we just move the blk_mq_abort_requeue_list call before
> > del_gendisk in general?
> 
> That may cause data loss if queue isn't killed. Normally queue is only killed
> when the controller is dead(such as in reset failure) or !pci_device_is_present()
> (in nvme_remove()).

But in your test, your controller isn't even dead. Why are we killing
it when it's still functional? I think we need to first not consider
this perfectly functional controller to be dead under these conditions,
and second, understand why killing the queues after del_gendisk is called
does not allow forward progress.

  reply	other threads:[~2017-05-18 16:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17  1:27 [PATCH 0/2] nvme: fix hang in path of removing disk Ming Lei
2017-05-17  1:27 ` Ming Lei
2017-05-17  1:27 ` [PATCH 1/2] nvme: fix race between removing and reseting failure Ming Lei
2017-05-17  1:27   ` Ming Lei
2017-05-17  6:38   ` Johannes Thumshirn
2017-05-17  6:38     ` Johannes Thumshirn
2017-05-17  7:01     ` Ming Lei
2017-05-17  7:01       ` Ming Lei
2017-05-18 13:47   ` Christoph Hellwig
2017-05-18 13:47     ` Christoph Hellwig
2017-05-18 15:04     ` Ming Lei
2017-05-18 15:04       ` Ming Lei
2017-05-18 14:13   ` Keith Busch
2017-05-18 14:13     ` Keith Busch
2017-05-19 12:52     ` Ming Lei
2017-05-19 12:52       ` Ming Lei
2017-05-19 15:15       ` Keith Busch
2017-05-19 15:15         ` Keith Busch
2017-05-19 14:41   ` Jens Axboe
2017-05-19 14:41     ` Jens Axboe
2017-05-19 15:10     ` Ming Lei
2017-05-19 15:10       ` Ming Lei
2017-05-19 16:40     ` Ming Lei
2017-05-19 16:40       ` Ming Lei
2017-05-19 16:55       ` yizhan
2017-05-19 16:55         ` yizhan
2017-05-17  1:27 ` [PATCH 2/2] nvme: avoid to hang in remove disk Ming Lei
2017-05-17  1:27   ` Ming Lei
2017-05-18 13:49   ` Christoph Hellwig
2017-05-18 13:49     ` Christoph Hellwig
2017-05-18 15:35     ` Ming Lei
2017-05-18 15:35       ` Ming Lei
2017-05-18 16:06       ` Keith Busch [this message]
2017-05-18 16:06         ` Keith Busch
2017-05-19 13:19         ` Ming Lei
2017-05-19 13:19           ` Ming Lei

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=20170518160624.GA6015@localhost.localdomain \
    --to=keith.busch@intel.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=ming.lei@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=stable@vger.kernel.org \
    --cc=yizhan@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.