Re: [PATCH 2/2] nvme-core: Fix deadlock when deleting the ctrl while scanning

From: Sagi Grimberg
Date: Fri Jul 19 2019 - 16:20:50 EST



[1]:
Or actually:
--
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 76cd3dd8736a..a0e2072fe73e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3576,6 +3576,12 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
ÂÂÂÂÂÂÂ struct nvme_ns *ns, *next;
ÂÂÂÂÂÂÂ LIST_HEAD(ns_list);

+ÂÂÂÂÂÂ mutex_lock(&ctrl->scan_lock);
+ÂÂÂÂÂÂ list_for_each_entry(ns, &ctrl->namespaces, list)
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (nvme_mpath_clear_current_path(ns))
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ kblockd_schedule_work(&ns->head->requeue_work);
+ÂÂÂÂÂÂ mutex_lock(&ctrl->scan_lock);

This should be mutex_unlock of course...