NVMe: Fix FS mount issue (hot-remove followed by hot-add)
authorIndraneel M <indraneel.m@samsung.com>
Thu, 11 Dec 2014 15:24:18 +0000 (08:24 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 11 Dec 2014 15:24:18 +0000 (08:24 -0700)
After Hot-remove of a device with a mounted partition,
when the device is hot-added again, the new node reappears
as nvme0n1. Mounting this new node fails with the error:

mount: mount /dev/nvme0n1p1 on /mnt failed: File exists.

The old nodes's FS entries still exist and the kernel can't re-create
procfs and sysfs entries for the new node with the same name.
The patch fixes this issue.

Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Indraneel M <indraneel.m@samsung.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/nvme-core.c

index 2cc2cee7a3670d27dfe57eb9d1ddf4dc3c8b250a..95f2310255ceec799172be317f2f9a0ce7add6b3 100644 (file)
@@ -2493,6 +2493,7 @@ static void nvme_free_dev(struct kref *kref)
 
        pci_dev_put(dev->pci_dev);
        nvme_free_namespaces(dev);
+       nvme_release_instance(dev);
        blk_mq_free_tag_set(&dev->tagset);
        kfree(dev->queues);
        kfree(dev->entry);
@@ -2780,7 +2781,6 @@ static void nvme_remove(struct pci_dev *pdev)
        nvme_dev_remove_admin(dev);
        nvme_free_queues(dev, 0);
        nvme_free_admin_tags(dev);
-       nvme_release_instance(dev);
        nvme_release_prp_pools(dev);
        kref_put(&dev->kref, nvme_free_dev);
 }