[PATCH 3/3] nvme-multipath: skip inaccessible paths during partition scan
Hannes Reinecke
hare at kernel.org
Wed Sep 11 02:51:07 PDT 2024
When a path is switched to 'inaccessible' during partition scan
triggered via device_add_disk() and we only have one path the
system will be stuck as nvme_available_path() will always return
'true'. So I/O will never be completed and the system is stuck
in device_add_disk().
This patch introduces a flag NVME_NSHEAD_DISABLE_QUEUEING to
cause nvme_available_path() to always return NULL, and with
that I/O to be failed if all paths are unavailable.
Signed-off-by: Hannes Reinecke <hare at kernel.org>
---
drivers/nvme/host/multipath.c | 10 +++++++++-
drivers/nvme/host/nvme.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index f72c5a6a2d8e..bcd70755c663 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -421,7 +421,8 @@ static bool nvme_available_path(struct nvme_ns_head *head)
{
struct nvme_ns *ns;
- if (!test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags))
+ if (!test_bit(NVME_NSHEAD_DISK_LIVE, &head->flags) ||
+ test_bit(NVME_NSHEAD_DISABLE_QUEUEING, &head->flags))
return NULL;
list_for_each_entry_rcu(ns, &head->list, siblings) {
@@ -646,8 +647,15 @@ static void nvme_mpath_set_live(struct nvme_ns *ns)
* head.
*/
if (!test_and_set_bit(NVME_NSHEAD_DISK_LIVE, &head->flags)) {
+ /*
+ * Disable queueing to ensure I/O is not retried on unusable
+ * paths, which would cause the system to be stuck during
+ * partition scan.
+ */
+ set_bit(NVME_NSHEAD_DISABLE_QUEUEING, &head->flags);
rc = device_add_disk(&head->subsys->dev, head->disk,
nvme_ns_attr_groups);
+ clear_bit(NVME_NSHEAD_DISABLE_QUEUEING, &head->flags);
if (rc) {
clear_bit(NVME_NSHEAD_DISK_LIVE, &head->flags);
return;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 50515ad0f9d6..f45ca7c45fd2 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -493,6 +493,7 @@ struct nvme_ns_head {
struct mutex lock;
unsigned long flags;
#define NVME_NSHEAD_DISK_LIVE 0
+#define NVME_NSHEAD_DISABLE_QUEUEING 1
struct nvme_ns __rcu *current_path[];
#endif
};
--
2.35.3
More information about the Linux-nvme
mailing list