[PATCH v2 01/22] nvmet: add context annotation for nvmet_ns::bdev

Bart Van Assche bvanassche at acm.org
Wed Nov 18 16:25:56 PST 2026


On 11/17/26 11:34 PM, Nilay Shroff wrote:
> +/*
> + * The accessors generated by this macro are annotated with __context_unsafe()
> + * because they are intended for use in I/O hotpaths and request-processing
> + * paths where a namespace reference is held. These paths access namespace
> + * fields that are guaranteed not to change while the reference is held and the
> + * I/O or request processing is in progress.
> + */
> +#define NVMET_NS_ACCESSOR(_type, _name)					    \
> +static inline _type nvmet_ns_##_name(struct nvmet_ns *ns)		    \
> +	__context_unsafe(/* access _name after getting ns reference */)	    \
> +{									    \
> +	return ns->_name;						    \
> +}

Lock context analysis enables thread-safety checking at compile time.
The accessors defined by NVMET_NS_ACCESSOR() disable compile time
thread-safety checks. So these accessors defeat the purpose of this
patch series, isn't it?

Thanks,

Bart.



More information about the Linux-nvme mailing list