[PATCH 2/2] nvme-multipath: retry partition scan on errors
Hannes Reinecke
hare at kernel.org
Tue Oct 8 06:57:29 PDT 2024
When we hit I/O errors during partition scan we can assume that
partition scanning was incomplete. Rather than continue to work
with an incomplete device we should disable the disk completely,
and wait for a rescan to retry again.
Signed-off-by: Hannes Reinecke <hare at kernel.org>
---
drivers/nvme/host/multipath.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 68eb1df98419..f70952c6d683 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -243,6 +243,21 @@ void nvme_mpath_revalidate_paths(struct nvme_ns *ns)
kblockd_schedule_work(&head->requeue_work);
}
+static bool nvme_scan_errors(struct nvme_ns_head *head)
+{
+ int srcu_idx, valid = 0;
+ struct nvme_ns *ns;
+
+ srcu_idx = srcu_read_lock(&head->srcu);
+ list_for_each_entry_rcu(ns, &head->list, siblings) {
+ if (!test_bit(NVME_NS_SCAN_FAILED, &ns->flags))
+ valid++;
+ }
+ srcu_read_unlock(&head->srcu, srcu_idx);
+
+ return !valid;
+}
+
static bool nvme_path_is_disabled(struct nvme_ns *ns)
{
enum nvme_ctrl_state state = nvme_ctrl_state(ns->ctrl);
@@ -670,6 +685,11 @@ static void nvme_mpath_set_live(struct nvme_ns *ns)
clear_bit(NVME_NSHEAD_DISK_LIVE, &head->flags);
return;
}
+ if (nvme_scan_errors(head)) {
+ del_gendisk(head->disk);
+ clear_bit(NVME_NSHEAD_DISK_LIVE, &head->flags);
+ return;
+ }
nvme_add_ns_head_cdev(head);
}
--
2.35.3
More information about the Linux-nvme
mailing list