[PATCH v2 22/22] nvmet: add context annotation for nvmet_ns::debugfs_dir
Nilay Shroff
nilay at linux.ibm.com
Tue Nov 17 23:35:03 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_setup() and nvmet_debugfs_ns_free() with
__must_hold(&ns->subsys->lock) to make its locking requirement explicit.
Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
drivers/nvme/target/debugfs.h | 6 ++++--
drivers/nvme/target/nvmet.h | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/target/debugfs.h b/drivers/nvme/target/debugfs.h
index b559d254fc2a..ebab05ddf3e6 100644
--- a/drivers/nvme/target/debugfs.h
+++ b/drivers/nvme/target/debugfs.h
@@ -14,8 +14,10 @@ int nvmet_debugfs_subsys_setup(struct nvmet_subsys *subsys);
void nvmet_debugfs_subsys_free(struct nvmet_subsys *subsys);
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);
-void nvmet_debugfs_ns_free(struct nvmet_ns *ns);
+void nvmet_debugfs_ns_setup(struct nvmet_ns *ns)
+ __must_hold(&ns->subsys->lock);
+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 1123c9c708df..e6309960f026 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -197,7 +197,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