]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
NVMe: Fix reset/remove race
authorKeith Busch <keith.busch@intel.com>
Tue, 19 Jul 2016 21:36:57 +0000 (15:36 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 9 Aug 2016 13:07:40 +0000 (15:07 +0200)
BugLink: http://bugs.launchpad.net/bugs/1602724
This fixes a scenario where device is present and being reset, but a
request to unbind the driver occurs.

A previous patch series addressing a device failure removal scenario
flushed reset_work after controller disable to unblock reset_work waiting
on a completion that wouldn't occur. This isn't safe as-is. The broken
scenario can potentially be induced with:

  modprobe nvme && modprobe -r nvme

To fix, the reset work is flushed immediately after setting the controller
removing flag, and any subsequent reset will not proceed with controller
initialization if the flag is set.

The controller status must be polled while active, so the watchdog timer
is also left active until the controller is disabled to cleanup requests
that may be stuck during namespace removal.

[Fixes: ff23a2a15a2117245b4599c1352343c8b8fb4c43]
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 9bf2b972afeaffd173fe2ce211ebc555ea7e8a87)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
drivers/nvme/host/pci.c

index 05f3f66eebb8812971f94fc81c87a6da0a5a4840..1d2c6a59f90e4349bd670fd56141b4221fbb56d9 100644 (file)
@@ -1874,6 +1874,9 @@ static void nvme_reset_work(struct work_struct *work)
        if (dev->bar)
                nvme_dev_disable(dev, false);
 
+       if (test_bit(NVME_CTRL_REMOVING, &dev->flags))
+               goto out;
+
        set_bit(NVME_CTRL_RESETTING, &dev->flags);
 
        result = nvme_dev_map(dev);
@@ -2077,8 +2080,6 @@ 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);