Re: [PATCH v2 20/26] null_blk: Enable lock context analysis

Nilay Shroff
2026-03-30T10:29:24Z

On 3/26/26 3:15 AM, Bart Van Assche wrote:
> Convert __releases() __acquires() into __must_hold(). Add __must_hold()
> annotations where these are missing. Annotate two functions that use
> conditional locking with __no_context_analysis. Enable lock context
> analysis in the Makefile.
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/block/null_blk/Makefile | 2 ++
> drivers/block/null_blk/main.c | 7 +++++--
> drivers/block/null_blk/zoned.c | 2 ++
> 3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/null_blk/Makefile b/drivers/block/null_blk/Makefile
> index 84c36e512ab8..282b0d51a477 100644
> --- a/drivers/block/null_blk/Makefile
> +++ b/drivers/block/null_blk/Makefile
> @@ -1,5 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0
>
> +CONTEXT_ANALYSIS := y
> +
> # needed for trace events
> ccflags-y += -I$(src)
>
> diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
> index f8c0fd57e041..677ac829ef80 100644
> --- a/drivers/block/null_blk/main.c
> +++ b/drivers/block/null_blk/main.c
> @@ -1004,8 +1004,7 @@ static struct nullb_page *null_lookup_page(struct nullb *nullb,
>
> static struct nullb_page *null_insert_page(struct nullb *nullb,
> sector_t sector, bool ignore_cache)
> - __releases(&nullb->lock)
> - __acquires(&nullb->lock)
> + __must_hold(&nullb->lock)

This function temporarily drops the &nullb->lock and requires it.
So why do we need to replace __releases/__acquires with __must_hold?
This is not clear.

[...]

> diff --git a/drivers/block/null_blk/zoned.c b/drivers/block/null_blk/zoned.c
> index 384bdce6a9b7..a7f94e76034f 100644
> --- a/drivers/block/null_blk/zoned.c
> +++ b/drivers/block/null_blk/zoned.c
> @@ -32,6 +32,7 @@ static inline void null_init_zone_lock(struct nullb_device *dev,
>
> static inline void null_lock_zone(struct nullb_device *dev,
> struct nullb_zone *zone)
> + __no_context_analysis /* conditional locking */

I see we already have __context_unsafe(comment) macro defined
which may be used instead for inline comment.

Thanks,
--Nilay