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 3/3] nvme-multipath: skip inaccessible paths during partition scan
Date: Wed, 11 Sep 2024 11:51:07 +0200 [thread overview]
Message-ID: <20240911095107.121688-4-hare@kernel.org> (raw)
In-Reply-To: <20240911095107.121688-1-hare@kernel.org>
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@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
next prev parent reply other threads:[~2024-09-11 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 9:51 [PATCHv6 0/3] nvme: NSHEAD_DISK_LIVE fixes Hannes Reinecke
2024-09-11 9:51 ` [PATCH 1/3] nvme-multipath: fixup typo when clearing DISK_LIVE Hannes Reinecke
2024-09-11 9:51 ` [PATCH 2/3] nvme-multipath: avoid hang on inaccessible namespaces Hannes Reinecke
2024-09-11 9:51 ` Hannes Reinecke [this message]
2024-09-11 11:24 ` [PATCH 3/3] nvme-multipath: skip inaccessible paths during partition scan Sagi Grimberg
2024-09-11 12:04 ` Hannes Reinecke
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=20240911095107.121688-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).