[PATCH 23/23] nvmet: add context annotation for nvmet_ns::debugfs_dir

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


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

Also, mark nvmet_debugfs_ns_free() with __must_hold(&subsys->lock) to
make its locking requirement explicit.

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

diff --git a/drivers/nvme/target/debugfs.h b/drivers/nvme/target/debugfs.h
index 2dde79e8a2ab..ebab05ddf3e6 100644
--- a/drivers/nvme/target/debugfs.h
+++ b/drivers/nvme/target/debugfs.h
@@ -16,7 +16,8 @@ int nvmet_debugfs_ctrl_setup(struct nvmet_ctrl *ctrl);
 void nvmet_debugfs_ctrl_free(struct nvmet_ctrl *ctrl);
 void nvmet_debugfs_ns_setup(struct nvmet_ns *ns)
 	__must_hold(&ns->subsys->lock);
-void nvmet_debugfs_ns_free(struct nvmet_ns *ns);
+void nvmet_debugfs_ns_free(struct nvmet_ns *ns)
+	__must_hold(&ns->subsys->lock);
 
 int __init nvmet_init_debugfs(void);
 void nvmet_exit_debugfs(void);
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 77d518739f91..a85874992c19 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -198,7 +198,8 @@ struct nvmet_ns {
 	struct nvmet_pr		pr;
 	struct xarray		pr_per_ctrl_refs;
 #ifdef CONFIG_NVME_TARGET_DEBUGFS
-	struct dentry		*debugfs_dir;
+	struct dentry		*debugfs_dir
+		__guarded_by(&subsys->lock);
 #endif
 };
 
-- 
2.53.0




More information about the Linux-nvme mailing list