Skip to content

Commit

Permalink
nvme: multipath: round-robin: eliminate "fallback" variable
Browse files Browse the repository at this point in the history
If we find an optimized path, we quit the loop immediately. Thus we can use
just one variable for the next path, slighly simplifying the code.

Signed-off-by: Martin Wilck <[email protected]>
Reviewed-by: Keith Busch <[email protected]>
Signed-off-by: Sagi Grimberg <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
mwilck authored and axboe committed Aug 21, 2020
1 parent 93eb038 commit e398863
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/nvme/host/multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static struct nvme_ns *nvme_next_ns(struct nvme_ns_head *head,
static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
int node, struct nvme_ns *old)
{
struct nvme_ns *ns, *found, *fallback = NULL;
struct nvme_ns *ns, *found = NULL;

if (list_is_singular(&head->list)) {
if (nvme_path_is_disabled(old))
Expand All @@ -252,7 +252,7 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
goto out;
}
if (ns->ana_state == NVME_ANA_NONOPTIMIZED)
fallback = ns;
found = ns;
}

/*
Expand All @@ -263,12 +263,11 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
*/
if (!nvme_path_is_disabled(old) &&
(old->ana_state == NVME_ANA_OPTIMIZED ||
(!fallback && old->ana_state == NVME_ANA_NONOPTIMIZED)))
(!found && old->ana_state == NVME_ANA_NONOPTIMIZED)))
return old;

if (!fallback)
if (!found)
return NULL;
found = fallback;
out:
rcu_assign_pointer(head->current_path[node], found);
return found;
Expand Down

0 comments on commit e398863

Please sign in to comment.