[PATCH 19/23] nvmet: add context annotation for PCI P2P parameters in struct nvmet_ns

Nilay Shroff nilay at linux.ibm.com
Sun Nov 8 19:28:24 PST 2026


nvmet_ns::p2p_dev and nvmet_ns::use_p2pmem are protected by
nvmet_subsys::lock. Annotate it with __guarded_by(&subsys->lock) so
that the clang context analyzer can validate accesses to this field.

Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
 drivers/nvme/target/nvmet.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index fa932c1fbf29..9e7a3992bb76 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -185,8 +185,10 @@ struct nvmet_ns {
 	struct completion	disable_done;
 	mempool_t		*bvec_pool;
 
-	struct pci_dev		*p2p_dev;
-	int			use_p2pmem;
+	struct pci_dev		*p2p_dev
+		__guarded_by(&subsys->lock);
+	int			use_p2pmem
+		__guarded_by(&subsys->lock);
 	int			pi_type;
 	int			metadata_size;
 	u8			csi;
-- 
2.53.0




More information about the Linux-nvme mailing list