Skip to content

Commit 3d7c2fd

Browse files
johnmeneghinikeithbusch
authored andcommitted
nvme-multipath: prepare for "queue-depth" iopolicy
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 <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 210b1f6 commit 3d7c2fd

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/nvme/host/multipath.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,15 @@ static struct nvme_ns *nvme_next_ns(struct nvme_ns_head *head,
291291
return list_first_or_null_rcu(&head->list, struct nvme_ns, siblings);
292292
}
293293

294-
static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
295-
int node, struct nvme_ns *old)
294+
static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head)
296295
{
297296
struct nvme_ns *ns, *found = NULL;
297+
int node = numa_node_id();
298+
struct nvme_ns *old = srcu_dereference(head->current_path[node],
299+
&head->srcu);
300+
301+
if (unlikely(!old))
302+
return __nvme_find_path(head, node);
298303

299304
if (list_is_singular(&head->list)) {
300305
if (nvme_path_is_disabled(old))
@@ -340,22 +345,26 @@ static inline bool nvme_path_is_optimized(struct nvme_ns *ns)
340345
ns->ana_state == NVME_ANA_OPTIMIZED;
341346
}
342347

343-
inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
348+
static struct nvme_ns *nvme_numa_path(struct nvme_ns_head *head)
344349
{
345350
int node = numa_node_id();
346351
struct nvme_ns *ns;
347352

348353
ns = srcu_dereference(head->current_path[node], &head->srcu);
349354
if (unlikely(!ns))
350355
return __nvme_find_path(head, node);
351-
352-
if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR)
353-
return nvme_round_robin_path(head, node, ns);
354356
if (unlikely(!nvme_path_is_optimized(ns)))
355357
return __nvme_find_path(head, node);
356358
return ns;
357359
}
358360

361+
inline struct nvme_ns *nvme_find_path(struct nvme_ns_head *head)
362+
{
363+
if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_RR)
364+
return nvme_round_robin_path(head);
365+
return nvme_numa_path(head);
366+
}
367+
359368
static bool nvme_available_path(struct nvme_ns_head *head)
360369
{
361370
struct nvme_ns *ns;

0 commit comments

Comments
 (0)