]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
NVMe: Remove device management handles on remove
authorKeith Busch <keith.busch@intel.com>
Sat, 28 Nov 2015 14:41:02 +0000 (15:41 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 1 Jun 2017 20:40:47 +0000 (13:40 -0700)
We don't want to allow new references to open on a device that is
removed. This ties the lifetime of these handles to the physical device's
presence rather than to the open reference count.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit 53029b0441bbd263dbb2ee6429572b1732dad4de)

Orabug: 25130845

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c

index 8df1ed283386bcdff929d2fb81485964c8494c5d..d666cafc0f8b45669bf6112c0b2efc037665df22 100644 (file)
@@ -1083,17 +1083,22 @@ static void nvme_release_instance(struct nvme_ctrl *ctrl)
        spin_unlock(&dev_list_lock);
 }
 
-static void nvme_free_ctrl(struct kref *kref)
-{
-       struct nvme_ctrl *ctrl = container_of(kref, struct nvme_ctrl, kref);
+void nvme_uninit_ctrl(struct nvme_ctrl *ctrl)
+ {
+       device_remove_file(ctrl->device, &dev_attr_reset_controller);
+       device_destroy(nvme_class, MKDEV(nvme_char_major, ctrl->instance));
 
        spin_lock(&dev_list_lock);
        list_del(&ctrl->node);
        spin_unlock(&dev_list_lock);
+}
+
+static void nvme_free_ctrl(struct kref *kref)
+{
+       struct nvme_ctrl *ctrl = container_of(kref, struct nvme_ctrl, kref);
 
        put_device(ctrl->device);
        nvme_release_instance(ctrl);
-       device_destroy(nvme_class, MKDEV(nvme_char_major, ctrl->instance));
 
        ctrl->ops->free_ctrl(ctrl);
 }
index a5ecf08c84067a397a1061ec9e44c95d4cb98153..305f55ae676fd76a7953874a8b6b0ab898e1a048 100644 (file)
@@ -214,6 +214,7 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap);
 int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl);
 int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
                const struct nvme_ctrl_ops *ops, unsigned long quirks);
+void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);
 void nvme_put_ctrl(struct nvme_ctrl *ctrl);
 int nvme_init_identify(struct nvme_ctrl *ctrl);
 
index 056d23b1156c007ef20fd777f755097744c97c7f..8293444df98f91f746d8971514dbe6b7cb7355aa 100644 (file)
@@ -2417,6 +2417,7 @@ static void nvme_remove(struct pci_dev *pdev)
        flush_work(&dev->reset_work);
        flush_work(&dev->scan_work);
        nvme_remove_namespaces(&dev->ctrl);
+       nvme_uninit_ctrl(&dev->ctrl);
        nvme_dev_shutdown(dev);
        nvme_dev_remove_admin(dev);
        nvme_free_queues(dev, 0);