Skip to content

Commit 2a08960

Browse files
ttooxxaagregkh
authored andcommitted
nvme-multipath: fix ANA state updates when a namespace is not present
[ Upstream commit 79f528a ] nvme_update_ana_state() has a deficiency that results in a failure to properly update the ana state for a namespace in the following case: NSIDs in ctrl->namespaces: 1, 3, 4 NSIDs in desc->nsids: 1, 2, 3, 4 Loop iteration 0: ns index = 0, n = 0, ns->head->ns_id = 1, nsid = 1, MATCH. Loop iteration 1: ns index = 1, n = 1, ns->head->ns_id = 3, nsid = 2, NO MATCH. Loop iteration 2: ns index = 2, n = 2, ns->head->ns_id = 4, nsid = 4, MATCH. Where the update to the ANA state of NSID 3 is missed. To fix this increment n and retry the update with the same ns when ns->head->ns_id is higher than nsid, Signed-off-by: Anton Eidelman <anton@lightbitslabs.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 372d3e6 commit 2a08960

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎drivers/nvme/host/multipath.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,17 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl,
509509

510510
down_read(&ctrl->namespaces_rwsem);
511511
list_for_each_entry(ns, &ctrl->namespaces, list) {
512-
unsigned nsid = le32_to_cpu(desc->nsids[n]);
513-
512+
unsigned nsid;
513+
again:
514+
nsid = le32_to_cpu(desc->nsids[n]);
514515
if (ns->head->ns_id < nsid)
515516
continue;
516517
if (ns->head->ns_id == nsid)
517518
nvme_update_ns_ana_state(desc, ns);
518519
if (++n == nr_nsids)
519520
break;
521+
if (ns->head->ns_id > nsid)
522+
goto again;
520523
}
521524
up_read(&ctrl->namespaces_rwsem);
522525
return 0;

0 commit comments

Comments
 (0)