From: hare@kernel.org
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>, Sagi Grimberg <sagi@grimberg.me>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>,
Hannes Reinecke <hare@kernel.org>
Subject: [PATCH 1/6] nvme-multipath: do not assign ->current_path in __nvme_find_path()
Date: Tue, 29 Jul 2025 09:06:48 +0200 [thread overview]
Message-ID: <20250729070653.125258-2-hare@kernel.org> (raw)
In-Reply-To: <20250729070653.125258-1-hare@kernel.org>
From: Hannes Reinecke <hare@suse.de>
__nvme_find_path() is the fallback if no paths are selected, but
setting ->current_path[] is only relevant for 'numa' and 'round-robin'
iopolicies. So move it out of __nvme_find_path() to avoid a pointless
assignment for other path checkers.
Signed-off-by: Hannes Reinecke <hare@kernel.org>
---
drivers/nvme/host/multipath.c | 40 +++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 3da980dc60d9..116b2e71d339 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -342,8 +342,6 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node)
if (!found)
found = fallback;
- if (found)
- rcu_assign_pointer(head->current_path[node], found);
return found;
}
@@ -364,8 +362,13 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head)
struct nvme_ns *old = srcu_dereference(head->current_path[node],
&head->srcu);
- if (unlikely(!old))
- return __nvme_find_path(head, node);
+ if (unlikely(!old)) {
+ ns = __nvme_find_path(head, node);
+ if (ns)
+ rcu_assign_pointer(head->current_path[node], found);
+ return ns;
+ }
+
if (list_is_singular(&head->list)) {
if (nvme_path_is_disabled(old))
@@ -455,9 +458,11 @@ static struct nvme_ns *nvme_numa_path(struct nvme_ns_head *head)
ns = srcu_dereference(head->current_path[node], &head->srcu);
if (unlikely(!ns))
- return __nvme_find_path(head, node);
- if (unlikely(!nvme_path_is_optimized(ns)))
- return __nvme_find_path(head, node);
+ ns = __nvme_find_path(head, node);
+ else if (unlikely(!nvme_path_is_optimized(ns)))
+ ns = __nvme_find_path(head, node);
+ if (ns)
+ rcu_assign_pointer(head->current_path[node], found);
return ns;
}
@@ -798,12 +803,21 @@ static void nvme_mpath_set_live(struct nvme_ns *ns)
mutex_lock(&head->lock);
if (nvme_path_is_optimized(ns)) {
- int node, srcu_idx;
-
- srcu_idx = srcu_read_lock(&head->srcu);
- for_each_online_node(node)
- __nvme_find_path(head, node);
- srcu_read_unlock(&head->srcu, srcu_idx);
+ int srcu_idx, iopolicy;
+
+ iopolicy = READ_ONCE(head->subsys->iopolicy);
+ if (iopolicy == NVME_IOPOLICY_NUMA ||
+ iopolicy == NVME_IOPOLICY_RR) {
+ int node;
+
+ srcu_idx = srcu_read_lock(&head->srcu);
+ for_each_online_node(node) {
+ struct nvme_ns *ns = __nvme_find_path(head, node);
+ if (ns)
+ rcu_assign_pointer(head->current_path[node], ns);
+ }
+ srcu_read_unlock(&head->srcu, srcu_idx);
+ }
}
mutex_unlock(&head->lock);
--
2.43.0
next prev parent reply other threads:[~2025-07-29 7:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-29 7:06 [RFC PATCH 0/6] nvme multipath eBPF path selector hare
2025-07-29 7:06 ` hare [this message]
2025-07-29 7:06 ` [PATCH 2/6] nvme: export nvme_find_get_subsystem()/nvme_put_subsystem() hare
2025-07-29 7:06 ` [PATCH 3/6] nvme: add per-namespace iopolicy sysfs attribute hare
2025-07-29 7:06 ` [PATCH 4/6] nvme: add 'sector' parameter to nvme_find_path() hare
2025-07-29 7:06 ` [PATCH 5/6] nvme-bpf: eBPF struct_ops path selectors hare
2025-07-29 7:06 ` [PATCH 6/6] tools/testing/selftests: add sample nvme bpf path selector hare
2025-07-30 2:03 ` Geliang Tang
2025-07-30 5:56 ` Hannes Reinecke
2025-07-29 7:54 ` [RFC PATCH 0/6] nvme multipath eBPF " Christoph Hellwig
2025-07-29 14:53 ` Mike Christie
2025-07-30 14:06 ` Christoph Hellwig
2025-07-30 2:03 ` Geliang Tang
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=20250729070653.125258-2-hare@kernel.org \
--to=hare@kernel.org \
--cc=hare@suse.de \
--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.