All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
	linux-nvme@lists.infradead.org, Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 2/2] nvme-multipath: retry partition scan on errors
Date: Tue,  8 Oct 2024 15:57:29 +0200	[thread overview]
Message-ID: <20241008135729.68810-3-hare@kernel.org> (raw)
In-Reply-To: <20241008135729.68810-1-hare@kernel.org>

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@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



      parent reply	other threads:[~2024-10-08 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 13:57 [PATCHv2 0/2] nvme-multipath: fix deadlock in device_add_disk() Hannes Reinecke
2024-10-08 13:57 ` [PATCH 1/2] nvme: propagate I/O errors during partition scan Hannes Reinecke
2024-10-08 13:57 ` Hannes Reinecke [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241008135729.68810-3-hare@kernel.org \
    --to=hare@kernel.org \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.