mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-10 20:09:56 +00:00
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>
This commit is contained in:
committed by
Keith Busch
parent
80e653fab6
commit
20015410fb
@@ -513,9 +513,6 @@ static int nvmet_p2pmem_ns_enable(struct nvmet_ns *ns)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Note: ctrl->subsys->lock should be held when calling this function
|
|
||||||
*/
|
|
||||||
static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl,
|
static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl,
|
||||||
struct nvmet_ns *ns)
|
struct nvmet_ns *ns)
|
||||||
{
|
{
|
||||||
@@ -523,6 +520,8 @@ static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl,
|
|||||||
struct pci_dev *p2p_dev;
|
struct pci_dev *p2p_dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
lockdep_assert_held(&ctrl->subsys->lock);
|
||||||
|
|
||||||
if (!ctrl->p2p_client || !ns->use_p2pmem)
|
if (!ctrl->p2p_client || !ns->use_p2pmem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1539,15 +1538,14 @@ bool nvmet_host_allowed(struct nvmet_subsys *subsys, const char *hostnqn)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Note: ctrl->subsys->lock should be held when calling this function
|
|
||||||
*/
|
|
||||||
static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
|
static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
|
||||||
struct device *p2p_client)
|
struct device *p2p_client)
|
||||||
{
|
{
|
||||||
struct nvmet_ns *ns;
|
struct nvmet_ns *ns;
|
||||||
unsigned long idx;
|
unsigned long idx;
|
||||||
|
|
||||||
|
lockdep_assert_held(&ctrl->subsys->lock);
|
||||||
|
|
||||||
if (!p2p_client)
|
if (!p2p_client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1557,14 +1555,13 @@ static void nvmet_setup_p2p_ns_map(struct nvmet_ctrl *ctrl,
|
|||||||
nvmet_p2pmem_ns_add_p2p(ctrl, ns);
|
nvmet_p2pmem_ns_add_p2p(ctrl, ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Note: ctrl->subsys->lock should be held when calling this function
|
|
||||||
*/
|
|
||||||
static void nvmet_release_p2p_ns_map(struct nvmet_ctrl *ctrl)
|
static void nvmet_release_p2p_ns_map(struct nvmet_ctrl *ctrl)
|
||||||
{
|
{
|
||||||
struct radix_tree_iter iter;
|
struct radix_tree_iter iter;
|
||||||
void __rcu **slot;
|
void __rcu **slot;
|
||||||
|
|
||||||
|
lockdep_assert_held(&ctrl->subsys->lock);
|
||||||
|
|
||||||
radix_tree_for_each_slot(slot, &ctrl->p2p_ns_map, &iter, 0)
|
radix_tree_for_each_slot(slot, &ctrl->p2p_ns_map, &iter, 0)
|
||||||
pci_dev_put(radix_tree_deref_slot(slot));
|
pci_dev_put(radix_tree_deref_slot(slot));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user