diff options
author | Hannes Reinecke <hare@suse.de> | 2021-07-16 13:30:35 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2021-07-21 09:55:40 +0200 |
commit | 5396fdac56d87d04e75e5068c0c92d33625f51e7 (patch) | |
tree | e408a4a51c5cb8346153afededaf514483374a46 /drivers/nvme/host/multipath.c | |
parent | 7764656b108cd308c39e9a8554353b8f9ca232a3 (diff) | |
download | lwn-5396fdac56d87d04e75e5068c0c92d33625f51e7.tar.gz lwn-5396fdac56d87d04e75e5068c0c92d33625f51e7.zip |
nvme: fix refcounting imbalance when all paths are down
When the last path to a ns_head drops the current code
removes the ns_head from the subsystem list, but will only
delete the disk itself if the last reference to the ns_head
drops. This is causing an refcounting imbalance eg when
applications have a reference to the disk, as then they'll
never get notified that the disk is in fact dead.
This patch moves the call 'del_gendisk' into nvme_mpath_check_last_path(),
ensuring that the disk can be properly removed and applications get the
appropriate notifications.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/host/multipath.c')
-rw-r--r-- | drivers/nvme/host/multipath.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 0ea5298469c3..3f32c5e86bfc 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -760,14 +760,21 @@ void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id) #endif } -void nvme_mpath_remove_disk(struct nvme_ns_head *head) +void nvme_mpath_shutdown_disk(struct nvme_ns_head *head) { if (!head->disk) return; + kblockd_schedule_work(&head->requeue_work); if (head->disk->flags & GENHD_FL_UP) { nvme_cdev_del(&head->cdev, &head->cdev_device); del_gendisk(head->disk); } +} + +void nvme_mpath_remove_disk(struct nvme_ns_head *head) +{ + if (!head->disk) + return; blk_set_queue_dying(head->disk->queue); /* make sure all pending bios are cleaned up */ kblockd_schedule_work(&head->requeue_work); |