Skip to contentSkip to conversation

nvme: reset delayed remve_work after reconnect

PATCH Applied Keith Busch 3 participants 3 messages Jun 9, 2025 – Jun 11, 2025 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: reset delayed remve_work after reconnect

From: Keith Busch <[email protected]>

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.

---
 drivers/nvme/host/core.c      | 4 ++++
 drivers/nvme/host/multipath.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +4 -0
index 92697f98c601d..724f5732786c0 100644
@@ -4036,6 +4036,10 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
 	list_add_tail_rcu(&ns->siblings, &head->list);
 	ns->head = head;
 	mutex_unlock(&ctrl->subsys->lock);
+
+#ifdef CONFIG_NVME_MULTIPATH
+	cancel_delayed_work(&head->remove_work);
+#endif
 	return 0;
 
 out_put_ns_head:
drivers/nvme/host/multipath.c +1 -1
index 140079ff86e6b..1062467595f33 100644
@@ -1311,7 +1311,7 @@ void nvme_mpath_remove_disk(struct nvme_ns_head *head)
 		 */
 		if (!try_module_get(THIS_MODULE))
 			goto out;
-		queue_delayed_work(nvme_wq, &head->remove_work,
+		mod_delayed_work(nvme_wq, &head->remove_work,
 				head->delayed_removal_secs * HZ);
 	} else {
 		list_del_init(&head->entry);
Signature · 1 line
2.47.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Keith Busch

From: Keith Busch <[email protected]>

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.

Quoted 1 line

Looks good to me: