OSDN Git Service

nvme: tighten up state check for namespace scanning
authorChristoph Hellwig <hch@lst.de>
Tue, 26 Apr 2016 11:51:58 +0000 (13:51 +0200)
committerJens Axboe <axboe@fb.com>
Mon, 2 May 2016 15:09:23 +0000 (09:09 -0600)
We only should be scanning namespaces if the controller is live.  Currently
we call the function just before setting it live, so fix the code up to
move the call to nvme_queue_scan to just below the state change.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Acked-by Jon Derrick: <jonathan.derrick@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/host/pci.c

index 0cee236..9b2deba 100644 (file)
@@ -272,7 +272,7 @@ static void nvme_queue_scan(struct nvme_dev *dev)
         * Do not queue new scan work when a controller is reset during
         * removal.
         */
-       if (dev->ctrl.state != NVME_CTRL_DELETING)
+       if (dev->ctrl.state == NVME_CTRL_LIVE)
                queue_work(nvme_workq, &dev->scan_work);
 }
 
@@ -1659,7 +1659,6 @@ static int nvme_dev_add(struct nvme_dev *dev)
                nvme_free_queues(dev, dev->online_queues);
        }
 
-       nvme_queue_scan(dev);
        return 0;
 }
 
@@ -1893,6 +1892,9 @@ static void nvme_reset_work(struct work_struct *work)
                dev_warn(dev->ctrl.device, "failed to mark controller live\n");
                goto out;
        }
+
+       if (dev->online_queues > 1)
+               nvme_queue_scan(dev);
        return;
 
  out: