All of lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCHv2] NVMe: Fix reset/remove race
Date: Mon, 4 Apr 2016 19:14:15 +0000	[thread overview]
Message-ID: <20160404191414.GA21477@localhost.localdomain> (raw)
In-Reply-To: <57014716.5050901@grimberg.me>

On Sun, Apr 03, 2016@07:38:46PM +0300, sagig wrote:
> On 22/03/16 23:49, Keith Busch wrote:
> >  drivers/nvme/host/pci.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> >diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> >index 24ccda3..660ec84 100644
> >--- a/drivers/nvme/host/pci.c
> >+++ b/drivers/nvme/host/pci.c
> >@@ -1859,6 +1859,9 @@ static void nvme_reset_work(struct work_struct *work)
> >  	if (dev->ctrl.ctrl_config & NVME_CC_ENABLE)
> >  		nvme_dev_disable(dev, false);
> >+	if (test_bit(NVME_CTRL_REMOVING, &dev->flags))
> >+		goto out;
> >+
> >  	set_bit(NVME_CTRL_RESETTING, &dev->flags);
> >  	result = nvme_pci_enable(dev);
> >@@ -2078,11 +2081,10 @@ static void nvme_remove(struct pci_dev *pdev)
> >  {
> >  	struct nvme_dev *dev = pci_get_drvdata(pdev);
> >-	del_timer_sync(&dev->watchdog_timer);
> >-
> >  	set_bit(NVME_CTRL_REMOVING, &dev->flags);
> >  	pci_set_drvdata(pdev, NULL);
> >  	flush_work(&dev->async_work);
> >+	flush_work(&dev->reset_work);
> 
> Do we need the same for scan_work? AFAICT it can still
> sneak in while we're removing...

It is flushed in the very next line not included in your reply. :)

scan_work isn't queued again when the "NVME_CTRL_REMOVING" flag is set,
so we're safe from seeing that queue again.

      reply	other threads:[~2016-04-04 19:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 21:49 [PATCHv2] NVMe: Fix reset/remove race Keith Busch
2016-03-23  7:44 ` Christoph Hellwig
2016-03-23  7:56 ` Johannes Thumshirn
2016-04-03 16:38 ` sagig
2016-04-04 19:14   ` Keith Busch [this message]

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=20160404191414.GA21477@localhost.localdomain \
    --to=keith.busch@intel.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.