Skip to content

Commit 4ac7643

Browse files
frextritekeithbusch
authored andcommitted
nvmet: Pass lockdep expression to RCU lists
ctrl->subsys->namespaces and subsys->namespaces are traversed with list_for_each_entry_rcu outside an RCU read-side critical section but under the protection of ctrl->subsys->lock and subsys->lock respectively. Hence, add the corresponding lockdep expression to the list traversal primitive to silence false-positive lockdep warnings, and harden RCU lists. Reported-by: kbuild test robot <[email protected]> Reviewed-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Amol Grover <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent c92bdde commit 4ac7643

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/nvme/target/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
555555
} else {
556556
struct nvmet_ns *old;
557557

558-
list_for_each_entry_rcu(old, &subsys->namespaces, dev_link) {
558+
list_for_each_entry_rcu(old, &subsys->namespaces, dev_link,
559+
lockdep_is_held(&subsys->lock)) {
559560
BUG_ON(ns->nsid == old->nsid);
560561
if (ns->nsid < old->nsid)
561562
break;
@@ -1172,7 +1173,8 @@ static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
11721173

11731174
ctrl->p2p_client = get_device(req->p2p_client);
11741175

1175-
list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link)
1176+
list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
1177+
lockdep_is_held(&ctrl->subsys->lock))
11761178
nvmet_p2pmem_ns_add_p2p(ctrl, ns);
11771179
}
11781180

0 commit comments

Comments
 (0)