]> www.infradead.org Git - nvme.git/commitdiff
nvme-multipath: prepare for "queue-depth" iopolicy
authorJohn Meneghini <jmeneghi@redhat.com>
Tue, 25 Jun 2024 12:26:04 +0000 (08:26 -0400)
committerKeith Busch <kbusch@kernel.org>
Wed, 26 Jun 2024 16:45:57 +0000 (09:45 -0700)
This patch prepares for the introduction of a new iopolicy by breaking up
the nvme_find_path() code path into sub-routines.

Signed-off-by: John Meneghini <jmeneghi@redhat.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/multipath.c

index 8a4d0e377114d608b9445a71e04e565ddc4091d9..c0ccf956cdcd8ab4a47bd49389038ecac7422e91 100644 (file)
@@ -291,10 +291,15 @@ static struct nvme_ns *nvme_next_ns(struct nvme_ns_head *head,
        return list_first_or_null_rcu(&head->list, struct nvme_ns, siblings);
 }
 
-static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
-               int node, struct nvme_ns *old)
+static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head)
 {
        struct nvme_ns *ns, *found = NULL;
+       int node = numa_node_id();
+       struct nvme_ns *old = srcu_dereference(head->current_path[node],
+                                              &head->srcu);
+
+       if (unlikely(!old))
+               return __nvme_find_path(head, node);
 
        if (list_is_singular(&head->list)) {
                if (nvme_path_is_disabled(old))
@@ -340,7 +345,7 @@ static inline bool nvme_path_is_optimized(struct nvme_ns *ns)
                ns->ana_state == NVME_ANA_OPTIMIZED;
 }
 
-inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
+static struct nvme_ns *nvme_numa_path(struct nvme_ns_head *head)
 {
        int node = numa_node_id();
        struct nvme_ns *ns;
@@ -348,14 +353,18 @@ inline struct nvme_ns *nvme_find_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 (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR)
-               return nvme_round_robin_path(head, node, ns);
        if (unlikely(!nvme_path_is_optimized(ns)))
                return __nvme_find_path(head, node);
        return ns;
 }
 
+inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
+{
+       if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR)
+               return nvme_round_robin_path(head);
+       return nvme_numa_path(head);
+}
+
 static bool nvme_available_path(struct nvme_ns_head *head)
 {
        struct nvme_ns *ns;