[PATCHv2] NVMe: Fix reset/remove race

Keith Busch keith.busch at intel.com
Mon Apr 4 12:14:15 PDT 2016


On Sun, Apr 03, 2016 at 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.



More information about the Linux-nvme mailing list