[PATCH 06/23] nvmet: add context annotation for nvmet_ns::nsid
Bart Van Assche
bvanassche at acm.org
Mon Nov 9 13:56:41 PST 2026
On 11/8/26 7:28 PM, Nilay Shroff wrote:
> [ ... ]
1. Bisectability:
This patch causes Clang analyzer errors in nvmet_format_ana_group(),
nvmet_execute_identify_endgrp_list(), and
nvmet_execute_identify_nslist(),
which are only resolved in patch 07. Please reorder or squash patch 07.
2. Design:
ns->nsid is set once during nvmet_ns_alloc() and is immutable throughout
the lifetime of the namespace. It is never modified under
subsys->lock or
any other lock. Marking it __guarded_by(&subsys->lock) and creating
nvmet_ns_nsid() to bypass the annotation throughout the driver adds
unnecessary churn. Please drop the annotation on nsid.
> @@ -746,6 +755,12 @@ struct nvmet_ns *nvmet_ns_alloc(struct
nvmet_subsys *subsys, u32 nsid)
>
> init_completion(&ns->disable_done);
>
> + __assume_ctx_lock(&ns->subsys->lock);
> ns->nsid = nsid;
> ns->subsys = subsys;
Here and elsewhere, lockdep_assert_held() should be used instead of
__assume_ctx_lock(). Additionally, the lock state should only be
verified after the ns->subsys assignment.
Thanks,
Bart.
More information about the Linux-nvme
mailing list