[PATCH 03/23] nvmet: add context annotation for nvmet_ns::file
Bart Van Assche
bvanassche at acm.org
Mon Nov 9 13:53:14 PST 2026
On 11/8/26 7:28 PM, Nilay Shroff wrote:
> @@ -258,6 +258,19 @@ static void nvmet_file_flush_work(struct
work_struct *w)
> {
> struct nvmet_req *req = container_of(w, struct nvmet_req, f.work);
>
> + /*
> + * The flush work is scheduled from the I/O hotpath after acquiring
> + * a reference to the namespace. This ensures that the namespace
> + * cannot be modified while the I/O is in flight.
> + *
> + * nvmet_file_flush() requires callers to hold ns->subsys->lock.
> + * Since we already hold a namespace reference, explicitly assert
> + * the lock capability here to satisfy the context analyzer.
> + *
> + * Other callers of nvmet_file_flush() that do not hold a namespace
> + * reference must acquire ns->subsys->lock before invoking it.
> + */
> + __assume_ctx_lock(&req->ns->subsys->lock);
> nvmet_req_complete(req, nvmet_file_flush(req));
> }
This assertion is incorrect. __assume_ctx_lock() informs the compiler
that a capability is held when it is actually held (e.g. through an alias).
Here, nvmet_file_flush_work() runs in a workqueue without holding
subsys->lock. If lockdep_assert_held() were used here, Lockdep would
trigger a warning.
nvmet_file_flush() should not be annotated with
__must_hold(&req->ns->subsys->lock).
Thanks,
Bart.
More information about the Linux-nvme
mailing list