* [PATCH 1/2] block: Annotate the queue limits functions
2026-01-14 19:28 [PATCH 0/2] Fix an error path in disk_update_zone_resources() Bart Van Assche
@ 2026-01-14 19:28 ` Bart Van Assche
2026-01-15 6:26 ` Christoph Hellwig
2026-01-14 19:28 ` [PATCH 2/2] block: Fix an error path in disk_update_zone_resources() Bart Van Assche
2026-01-19 18:04 ` (subset) [PATCH 0/2] " Jens Axboe
2 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2026-01-14 19:28 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Christoph Hellwig, Damien Le Moal, Bart Van Assche
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
include/linux/blkdev.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 72e34acd439c..66bf11cfcb37 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1084,14 +1084,17 @@ static inline unsigned int blk_boundary_sectors_left(sector_t offset,
*/
static inline struct queue_limits
queue_limits_start_update(struct request_queue *q)
+ __acquires(&q->limits_lock)
{
mutex_lock(&q->limits_lock);
return q->limits;
}
int queue_limits_commit_update_frozen(struct request_queue *q,
- struct queue_limits *lim);
+ struct queue_limits *lim)
+ __releases(&q->limits_lock);
int queue_limits_commit_update(struct request_queue *q,
- struct queue_limits *lim);
+ struct queue_limits *lim)
+ __releases(&q->limits_lock);
int queue_limits_set(struct request_queue *q, struct queue_limits *lim);
int blk_validate_limits(struct queue_limits *lim);
@@ -1104,6 +1107,7 @@ int blk_validate_limits(struct queue_limits *lim);
* starting update.
*/
static inline void queue_limits_cancel_update(struct request_queue *q)
+ __releases(&q->limits_lock)
{
mutex_unlock(&q->limits_lock);
}
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/2] block: Annotate the queue limits functions
2026-01-14 19:28 ` [PATCH 1/2] block: Annotate the queue limits functions Bart Van Assche
@ 2026-01-15 6:26 ` Christoph Hellwig
2026-01-15 8:11 ` John Garry
0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2026-01-15 6:26 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Christoph Hellwig, Damien Le Moal
This is missing a commit log. And not really telling what kind
of annotation you're adding.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] block: Annotate the queue limits functions
2026-01-15 6:26 ` Christoph Hellwig
@ 2026-01-15 8:11 ` John Garry
2026-01-15 16:53 ` Bart Van Assche
0 siblings, 1 reply; 10+ messages in thread
From: John Garry @ 2026-01-15 8:11 UTC (permalink / raw)
To: Christoph Hellwig, Bart Van Assche
Cc: Jens Axboe, linux-block, Damien Le Moal
On 15/01/2026 06:26, Christoph Hellwig wrote:
> This is missing a commit log. And not really telling what kind
> of annotation you're adding.
>
>
And we removed these previously - see c3042a5403ef2.
Does sparse now handle mutexes?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] block: Annotate the queue limits functions
2026-01-15 8:11 ` John Garry
@ 2026-01-15 16:53 ` Bart Van Assche
2026-01-19 8:41 ` Christoph Hellwig
0 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2026-01-15 16:53 UTC (permalink / raw)
To: John Garry, Christoph Hellwig; +Cc: Jens Axboe, linux-block, Damien Le Moal
On 1/15/26 1:11 AM, John Garry wrote:
> On 15/01/2026 06:26, Christoph Hellwig wrote:
>> This is missing a commit log. And not really telling what kind
>> of annotation you're adding.
>
> And we removed these previously - see c3042a5403ef2.
>
> Does sparse now handle mutexes?
sparse is dead. The most recent commit is from February 2024 (almost two
years ago). Additionally, the sparse maintainer doesn't reply anymore to
emails or bug reports about sparse.
These annotations aren't for sparse - these are for clang. This patch
series has been queued by Peter Zijlstra on the tip master branch and is
expected to be sent to Linus during the next merge window: "[PATCH v5
00/36] Compiler-Based Context- and Locking-Analysis"
(https://lore.kernel.org/lkml/20251219154418.3592607-1-elver@google.com/).
There are some subtle differences between the sparse and clang lock
context attributes. Sparse only cares about lock context attributes on
the function implementation. Clang respects lock context annotations
whether these annotations occur on the function declaration or the
function definition. The former is preferred since this ensures that the
annotations are visible not only while compiling the function
implementation but also when compiling all callers of a function.
Bart.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] block: Annotate the queue limits functions
2026-01-15 16:53 ` Bart Van Assche
@ 2026-01-19 8:41 ` Christoph Hellwig
2026-01-20 13:42 ` Bart Van Assche
0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2026-01-19 8:41 UTC (permalink / raw)
To: Bart Van Assche
Cc: John Garry, Christoph Hellwig, Jens Axboe, linux-block,
Damien Le Moal
On Thu, Jan 15, 2026 at 08:53:32AM -0800, Bart Van Assche wrote:
> On 1/15/26 1:11 AM, John Garry wrote:
>> On 15/01/2026 06:26, Christoph Hellwig wrote:
>>> This is missing a commit log. And not really telling what kind
>>> of annotation you're adding.
>>
>> And we removed these previously - see c3042a5403ef2.
>>
>> Does sparse now handle mutexes?
>
> sparse is dead.
It's not. And even if it was we still need it.
> The most recent commit is from February 2024 (almost two
> years ago).
The repository disagrees:
commit fbdde3127b83e6d09e0ba808d7925dd84407f3c6 (origin/master, origin/HEAD)
Author: Dan Carpenter <dan.carpenter@linaro.org>
Date: Wed Oct 15 16:08:13 2025 +0300
builtin: implement __builtin_strlen() for constants
> Additionally, the sparse maintainer doesn't reply anymore to
> emails or bug reports about sparse.
While I'd love to see more activity, that is clearly untrue as well:
[PATCH v2 3/3] module: Add compile-time check for embedded NUL characters
> These annotations aren't for sparse - these are for clang. This patch
> series has been queued by Peter Zijlstra on the tip master branch and is
> expected to be sent to Linus during the next merge window: "[PATCH v5
> 00/36] Compiler-Based Context- and Locking-Analysis"
> (https://lore.kernel.org/lkml/20251219154418.3592607-1-elver@google.com/).
Until that actually becomes mainstream we can't break the existing
annotations.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 1/2] block: Annotate the queue limits functions
2026-01-19 8:41 ` Christoph Hellwig
@ 2026-01-20 13:42 ` Bart Van Assche
0 siblings, 0 replies; 10+ messages in thread
From: Bart Van Assche @ 2026-01-20 13:42 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: John Garry, Jens Axboe, linux-block, Damien Le Moal
On 1/19/26 12:41 AM, Christoph Hellwig wrote:
> On Thu, Jan 15, 2026 at 08:53:32AM -0800, Bart Van Assche wrote:
>> On 1/15/26 1:11 AM, John Garry wrote:
>>> On 15/01/2026 06:26, Christoph Hellwig wrote:
>>>> This is missing a commit log. And not really telling what kind
>>>> of annotation you're adding.
>>>
>>> And we removed these previously - see c3042a5403ef2.
>>>
>>> Does sparse now handle mutexes?
>>
>> sparse is dead.
>
> It's not. And even if it was we still need it.
Is there perhaps a new official sparse git repository? What I wrote
applies to the following repository:
https://github.com/lucvoo/sparse.git. After some searching, I found a
repository with more recent changes:
git://git.kernel.org/pub/scm/devel/sparse/sparse.git
There are 7 commits in the latter repository that are not in Luc Voo's
repository. Not much, but better than nothing.
And I found this email from September 2025: "Re: Sparse maintainership"
(https://lore.kernel.org/all/CACePvbU=fAf6nNih5r-epJwU8qpiJ4TmkU6yQg8O1hrJKznDRA@mail.gmail.com/)
Thanks,
Bart.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] block: Fix an error path in disk_update_zone_resources()
2026-01-14 19:28 [PATCH 0/2] Fix an error path in disk_update_zone_resources() Bart Van Assche
2026-01-14 19:28 ` [PATCH 1/2] block: Annotate the queue limits functions Bart Van Assche
@ 2026-01-14 19:28 ` Bart Van Assche
2026-01-15 6:26 ` Christoph Hellwig
2026-01-19 18:04 ` (subset) [PATCH 0/2] " Jens Axboe
2 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2026-01-14 19:28 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Christoph Hellwig, Damien Le Moal, Bart Van Assche,
Nathan Chancellor, Johannes Thumshirn, Chaitanya Kulkarni,
Hannes Reinecke
Any queue_limits_start_update() call must be followed either by a
queue_limits_commit_update() call or by a queue_limits_cancel_update()
call. Make sure that the error path near the start of
disk_update_zone_resources() follows this requirement. Remove the
"goto unfreeze" statement from that error path to make the code easier
to verify.
This was detected by annotating the queue_limits_*() calls with Clang
thread-safety attributes and by building the kernel with thread-safety
checking enabled. Without this patch and with thread-safety checking
enabled, the following error is reported:
block/blk-zoned.c:2020:1: error: mutex 'disk->queue->limits_lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
2020 | }
| ^
block/blk-zoned.c:1959:8: note: mutex acquired here
1959 | lim = queue_limits_start_update(q);
| ^
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Fixes: bba4322e3f30 ("block: freeze queue when updating zone resources")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
block/blk-zoned.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 1c54678fae6b..8000c94690ee 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -1957,6 +1957,7 @@ static int disk_update_zone_resources(struct gendisk *disk,
disk->nr_zones = args->nr_zones;
if (args->nr_conv_zones >= disk->nr_zones) {
+ queue_limits_cancel_update(q);
pr_warn("%s: Invalid number of conventional zones %u / %u\n",
disk->disk_name, args->nr_conv_zones, disk->nr_zones);
ret = -ENODEV;
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: (subset) [PATCH 0/2] Fix an error path in disk_update_zone_resources()
2026-01-14 19:28 [PATCH 0/2] Fix an error path in disk_update_zone_resources() Bart Van Assche
2026-01-14 19:28 ` [PATCH 1/2] block: Annotate the queue limits functions Bart Van Assche
2026-01-14 19:28 ` [PATCH 2/2] block: Fix an error path in disk_update_zone_resources() Bart Van Assche
@ 2026-01-19 18:04 ` Jens Axboe
2 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2026-01-19 18:04 UTC (permalink / raw)
To: Bart Van Assche; +Cc: linux-block, Christoph Hellwig, Damien Le Moal
On Wed, 14 Jan 2026 11:28:00 -0800, Bart Van Assche wrote:
> This patch series includes a fix for an error path in
> disk_update_zone_resources() and also the patch with which this bug was
> discovered. Compile-tested only.
>
> Please consider this patch series for inclusion in the upstream kernel.
>
> Thanks,
>
> [...]
Applied, thanks!
[2/2] block: Fix an error path in disk_update_zone_resources()
commit: 07a1bc5c14c9ef6401b21c1873c6c087075ff292
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 10+ messages in thread