Skip to content

Commit

Permalink
nvmet: Pass lockdep expression to RCU lists
Browse files Browse the repository at this point in the history
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 <lkp@intel.com>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Amol Grover <frextrite@gmail.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
  • Loading branch information
Amol Grover authored and Keith Busch committed Feb 3, 2020
1 parent c92bdde commit 4ac7643
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/nvme/target/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
} else {
struct nvmet_ns *old;

list_for_each_entry_rcu(old, &subsys->namespaces, dev_link) {
list_for_each_entry_rcu(old, &subsys->namespaces, dev_link,
lockdep_is_held(&subsys->lock)) {
BUG_ON(ns->nsid == old->nsid);
if (ns->nsid < old->nsid)
break;
Expand Down Expand Up @@ -1172,7 +1173,8 @@ static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,

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

list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link)
list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link,
lockdep_is_held(&ctrl->subsys->lock))
nvmet_p2pmem_ns_add_p2p(ctrl, ns);
}

Expand Down

0 comments on commit 4ac7643

Please sign in to comment.