* [PATCH] md: Fix linear_set_limits()
@ 2025-01-29 22:56 Bart Van Assche
2025-01-31 7:49 ` Christoph Hellwig
2025-01-31 18:45 ` Song Liu
0 siblings, 2 replies; 4+ messages in thread
From: Bart Van Assche @ 2025-01-29 22:56 UTC (permalink / raw)
To: Song Liu
Cc: linux-raid, Bart Van Assche, Yu Kuai, Coly Li, Mike Snitzer,
Christoph Hellwig, Nathan Chancellor
queue_limits_cancel_update() must only be called if
queue_limits_start_update() is called first. Remove the
queue_limits_cancel_update() call from linear_set_limits() because
there is no corresponding queue_limits_start_update() call.
This bug was discovered by annotating all mutex operations with clang
thread-safety attributes and by building the kernel with clang and
-Wthread-safety.
Cc: Yu Kuai <yukuai3@huawei.com>
Cc: Coly Li <colyli@kernel.org>
Cc: Mike Snitzer <snitzer@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Fixes: 127186cfb184 ("md: reintroduce md-linear")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/md/md-linear.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c
index a382929ce7ba..369aed044b40 100644
--- a/drivers/md/md-linear.c
+++ b/drivers/md/md-linear.c
@@ -76,10 +76,8 @@ static int linear_set_limits(struct mddev *mddev)
lim.max_write_zeroes_sectors = mddev->chunk_sectors;
lim.io_min = mddev->chunk_sectors << 9;
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
- if (err) {
- queue_limits_cancel_update(mddev->gendisk->queue);
+ if (err)
return err;
- }
return queue_limits_set(mddev->gendisk->queue, &lim);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] md: Fix linear_set_limits()
2025-01-29 22:56 [PATCH] md: Fix linear_set_limits() Bart Van Assche
@ 2025-01-31 7:49 ` Christoph Hellwig
2025-01-31 17:05 ` Bart Van Assche
2025-01-31 18:45 ` Song Liu
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2025-01-31 7:49 UTC (permalink / raw)
To: Bart Van Assche
Cc: Song Liu, linux-raid, Yu Kuai, Coly Li, Mike Snitzer,
Christoph Hellwig, Nathan Chancellor
On Wed, Jan 29, 2025 at 02:56:35PM -0800, Bart Van Assche wrote:
> queue_limits_cancel_update() must only be called if
> queue_limits_start_update() is called first. Remove the
> queue_limits_cancel_update() call from linear_set_limits() because
> there is no corresponding queue_limits_start_update() call.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
> This bug was discovered by annotating all mutex operations with clang
> thread-safety attributes and by building the kernel with clang and
> -Wthread-safety.
Can you send patches for that?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] md: Fix linear_set_limits()
2025-01-31 7:49 ` Christoph Hellwig
@ 2025-01-31 17:05 ` Bart Van Assche
0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2025-01-31 17:05 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Song Liu, linux-raid, Yu Kuai, Coly Li, Mike Snitzer,
Nathan Chancellor
On 1/30/25 11:49 PM, Christoph Hellwig wrote:
> On Wed, Jan 29, 2025 at 02:56:35PM -0800, Bart Van Assche wrote:
>> This bug was discovered by annotating all mutex operations with clang
>> thread-safety attributes and by building the kernel with clang and
>> -Wthread-safety.
>
> Can you send patches for that?
Sure, but it will take a few additional days before these will be ready
to be posted. My current plan is as follows:
- In a first phase, annotate struct mutex and the
mutex_lock()/mutex_unlock() calls and their variants only. This is
sufficient to detect locking bugs at compile time in error paths and
also to support GUARDED_BY() if neither the guard() macro nor the
scoped_guard() macro are used.
- Next, modify the clang compiler such that the guard() macro becomes
supported. The challenge with the guard() macro is that it creates an
alias for synchronization object pointers, that the cleanup function
is passed a pointer to the synchronization object alias and also that
alias analysis is not supported by the clang thread-safety analysis.
I have not yet decided how to implement this.
- Evaluate whether it's worth it to annotate other synchronization
objects than struct mutex.
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] md: Fix linear_set_limits()
2025-01-29 22:56 [PATCH] md: Fix linear_set_limits() Bart Van Assche
2025-01-31 7:49 ` Christoph Hellwig
@ 2025-01-31 18:45 ` Song Liu
1 sibling, 0 replies; 4+ messages in thread
From: Song Liu @ 2025-01-31 18:45 UTC (permalink / raw)
To: Bart Van Assche
Cc: linux-raid, Yu Kuai, Coly Li, Mike Snitzer, Christoph Hellwig,
Nathan Chancellor
On Wed, Jan 29, 2025 at 2:57 PM Bart Van Assche <bvanassche@acm.org> wrote:
>
> queue_limits_cancel_update() must only be called if
> queue_limits_start_update() is called first. Remove the
> queue_limits_cancel_update() call from linear_set_limits() because
> there is no corresponding queue_limits_start_update() call.
>
> This bug was discovered by annotating all mutex operations with clang
> thread-safety attributes and by building the kernel with clang and
> -Wthread-safety.
>
> Cc: Yu Kuai <yukuai3@huawei.com>
> Cc: Coly Li <colyli@kernel.org>
> Cc: Mike Snitzer <snitzer@kernel.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Fixes: 127186cfb184 ("md: reintroduce md-linear")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Applied to md-6.14 branch.
Thanks for the fix!
Song
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-31 18:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 22:56 [PATCH] md: Fix linear_set_limits() Bart Van Assche
2025-01-31 7:49 ` Christoph Hellwig
2025-01-31 17:05 ` Bart Van Assche
2025-01-31 18:45 ` Song Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).