Skip to content

Commit ca7ae5c

Browse files
hreineckeChristoph Hellwig
authored andcommitted
nvme-multipath: factor out a nvme_path_is_disabled helper
Factor our a common helper to check if a path has been disabled by something other than the per-namespace ANA state. Signed-off-by: Hannes Reinecke <[email protected]> [hch: split from a bigger patch] Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 81adb86 commit ca7ae5c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/nvme/host/multipath.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,19 @@ void nvme_mpath_clear_current_path(struct nvme_ns *ns)
123123
}
124124
}
125125

126+
static bool nvme_path_is_disabled(struct nvme_ns *ns)
127+
{
128+
return ns->ctrl->state != NVME_CTRL_LIVE ||
129+
test_bit(NVME_NS_ANA_PENDING, &ns->flags);
130+
}
131+
126132
static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node)
127133
{
128134
int found_distance = INT_MAX, fallback_distance = INT_MAX, distance;
129135
struct nvme_ns *found = NULL, *fallback = NULL, *ns;
130136

131137
list_for_each_entry_rcu(ns, &head->list, siblings) {
132-
if (ns->ctrl->state != NVME_CTRL_LIVE ||
133-
test_bit(NVME_NS_ANA_PENDING, &ns->flags))
138+
if (nvme_path_is_disabled(ns))
134139
continue;
135140

136141
if (READ_ONCE(head->subsys->iopolicy) == NVME_IOPOLICY_NUMA)
@@ -184,8 +189,7 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
184189
for (ns = nvme_next_ns(head, old);
185190
ns != old;
186191
ns = nvme_next_ns(head, ns)) {
187-
if (ns->ctrl->state != NVME_CTRL_LIVE ||
188-
test_bit(NVME_NS_ANA_PENDING, &ns->flags))
192+
if (nvme_path_is_disabled(ns))
189193
continue;
190194

191195
if (ns->ana_state == NVME_ANA_OPTIMIZED) {

0 commit comments

Comments
 (0)