Skip to content

Commit 2001541

Browse files
mgurtovoykeithbusch
authored andcommitted
nvmet: add safety check for subsys lock
Replace comment about required lock with a lockdep_assert_held() check in the following functions: - nvmet_p2pmem_ns_add_p2p() - nvmet_setup_p2p_ns_map() - nvmet_release_p2p_ns_map() This ensures the subsystem lock is held at runtime. Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 80e653f commit 2001541

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

drivers/nvme/target/core.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,15 @@ static int nvmet_p2pmem_ns_enable(struct nvmet_ns *ns)
513513
return 0;
514514
}
515515

516-
/*
517-
* Note: ctrl->subsys->lock should be held when calling this function
518-
*/
519516
static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl,
520517
struct nvmet_ns *ns)
521518
{
522519
struct device *clients[2];
523520
struct pci_dev *p2p_dev;
524521
int ret;
525522

523+
lockdep_assert_held(&ctrl->subsys->lock);
524+
526525
if (!ctrl->p2p_client || !ns->use_p2pmem)
527526
return;
528527

@@ -1539,15 +1538,14 @@ bool nvmet_host_allowed(struct nvmet_subsys *subsys, const char *hostnqn)
15391538
return false;
15401539
}
15411540

1542-
/*
1543-
* Note: ctrl->subsys->lock should be held when calling this function
1544-
*/
15451541
static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
15461542
struct device *p2p_client)
15471543
{
15481544
struct nvmet_ns *ns;
15491545
unsigned long idx;
15501546

1547+
lockdep_assert_held(&ctrl->subsys->lock);
1548+
15511549
if (!p2p_client)
15521550
return;
15531551

@@ -1557,14 +1555,13 @@ static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
15571555
nvmet_p2pmem_ns_add_p2p(ctrl, ns);
15581556
}
15591557

1560-
/*
1561-
* Note: ctrl->subsys->lock should be held when calling this function
1562-
*/
15631558
static void nvmet_release_p2p_ns_map(struct nvmet_ctrl *ctrl)
15641559
{
15651560
struct radix_tree_iter iter;
15661561
void __rcu **slot;
15671562

1563+
lockdep_assert_held(&ctrl->subsys->lock);
1564+
15681565
radix_tree_for_each_slot(slot, &ctrl->p2p_ns_map, &iter, 0)
15691566
pci_dev_put(radix_tree_deref_slot(slot));
15701567

0 commit comments

Comments
 (0)