From: Daniel Wagner <dwagner@suse.de>
Date: Wed, 8 Dec 2021 09:51:41 +0100
Subject: nvme-multipath: Skip not ready namespaces when revalidating paths
Patch-mainline: Never, upstream refactored the bug away
References: bsc#1191793 bsc#1192507 bsc#1192969
Revalidating paths can happen at any time which races with creating
and initializing new namespaces (nvme_alloc_ns()). This can lead to
the situation that the new namespace has been added to the sibling
list (nvme_init_ns_head()) but the ns->disk pointer has not been
assigned while we start iterating over the sibling list in
nvme_mpath_revalidate_paths().
The initial idea check if list_empty(&ns->list) is not possible
because when the namespace object is destroyed, the ns->disk is reset
to NULL bevore it will be removed from the controler namespace list.
Thus just check if the ns->disk pointer is valid when iterating over
the sibling list.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
drivers/nvme/host/multipath.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 0e793f542a8c..cfa5780cb9f8 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -154,6 +154,8 @@ void nvme_mpath_revalidate_paths(struct nvme_ns *ns)
int node;
list_for_each_entry_rcu(ns, &head->list, siblings) {
+ if (!ns->disk)
+ continue;
if (capacity != get_capacity(ns->disk))
clear_bit(NVME_NS_READY, &ns->flags);
}
--
2.29.2