Skip to content

Commit dd2c185

Browse files
keithbuschChristoph Hellwig
authored andcommitted
nvme: reset delayed remove_work after reconnect
The remove_work will proceed with permanently disconnecting on the initial final path failure if the head shows no paths after the delay. If a new path connects while the remove_work is pending, and if that new path happens to disconnect before that remove_work executes, the delayed removal should reset based on the most recent path disconnect time, but queue_delayed_work() won't do anything if the work is already pending. Attempt to cancel the delayed work when a new path connects, and use mod_delayed_work() in case the remove_work remains pending anyway. Signed-off-by: Keith Busch <[email protected]> Reviewed-by: Nilay Shroff <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 4c8a951 commit dd2c185

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4036,6 +4036,10 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
40364036
list_add_tail_rcu(&ns->siblings, &head->list);
40374037
ns->head = head;
40384038
mutex_unlock(&ctrl->subsys->lock);
4039+
4040+
#ifdef CONFIG_NVME_MULTIPATH
4041+
cancel_delayed_work(&head->remove_work);
4042+
#endif
40394043
return 0;
40404044

40414045
out_put_ns_head:

drivers/nvme/host/multipath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
13111311
*/
13121312
if (!try_module_get(THIS_MODULE))
13131313
goto out;
1314-
queue_delayed_work(nvme_wq, &head->remove_work,
1314+
mod_delayed_work(nvme_wq, &head->remove_work,
13151315
head->delayed_removal_secs * HZ);
13161316
} else {
13171317
list_del_init(&head->entry);

0 commit comments

Comments
 (0)