drivers/md/raid5.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
From: Genjian Zhang <zhanggenjian@kylinos.cn>
make_discard_request() returns without completing the bio when reshape
is in progress. Discard callers block in submit_bio_wait()
waiting for a completion that never arrives. The caller hangs in
uninterruptible sleep, and this does not resolve when reshape finishes.
Complete the bio with BLK_STS_AGAIN so userspace can retry after reshape,
consistent with the existing policy of not processing discard during
reshape.
Tested on a loop-backed RAID5 array during mdadm --grow: without this
patch, blkdiscard hangs in bio_await() and remains in uninterruptible
sleep after md reports "reshape done"; with this patch it returns
-EAGAIN instead.
Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
---
drivers/md/raid5.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ffb5fcde54a9..4c3b42b2af85 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5722,9 +5722,11 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
if (WARN_ON_ONCE(bi->bi_opf & REQ_NOWAIT))
return;
- if (mddev->reshape_position != MaxSector)
+ if (mddev->reshape_position != MaxSector) {
/* Skip discard while reshape is happening */
+ bio_endio_status(bi, BLK_STS_AGAIN);
return;
+ }
if (!raid5_discard_limits(mddev, bi))
return;
--
2.43.0
Hi,
在 2026/7/12 0:13, Genjian 写道:
> From: Genjian Zhang <zhanggenjian@kylinos.cn>
>
> make_discard_request() returns without completing the bio when reshape
> is in progress. Discard callers block in submit_bio_wait()
> waiting for a completion that never arrives. The caller hangs in
> uninterruptible sleep, and this does not resolve when reshape finishes.
>
> Complete the bio with BLK_STS_AGAIN so userspace can retry after reshape,
> consistent with the existing policy of not processing discard during
> reshape.
>
> Tested on a loop-backed RAID5 array during mdadm --grow: without this
> patch, blkdiscard hangs in bio_await() and remains in uninterruptible
> sleep after md reports "reshape done"; with this patch it returns
> -EAGAIN instead.
>
> Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
> ---
> drivers/md/raid5.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index ffb5fcde54a9..4c3b42b2af85 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -5722,9 +5722,11 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
> if (WARN_ON_ONCE(bi->bi_opf & REQ_NOWAIT))
> return;
As nowait will be removed soon, I'm fine leaving it here.
Reviewed-by: Yu Kuai <yukuai@fygo.io>
>
> - if (mddev->reshape_position != MaxSector)
> + if (mddev->reshape_position != MaxSector) {
> /* Skip discard while reshape is happening */
> + bio_endio_status(bi, BLK_STS_AGAIN);
> return;
> + }
>
> if (!raid5_discard_limits(mddev, bi))
> return;
--
Thanks,
Kuai
At 2026-07-19 20:54:42, "yu kuai" <yukuai@fygo.io> wrote:
>Hi,
>
>在 2026/7/12 0:13, Genjian 写道:
>> From: Genjian Zhang <zhanggenjian@kylinos.cn>
>>
>> make_discard_request() returns without completing the bio when reshape
>> is in progress. Discard callers block in submit_bio_wait()
>> waiting for a completion that never arrives. The caller hangs in
>> uninterruptible sleep, and this does not resolve when reshape finishes.
>>
>> Complete the bio with BLK_STS_AGAIN so userspace can retry after reshape,
>> consistent with the existing policy of not processing discard during
>> reshape.
>>
>> Tested on a loop-backed RAID5 array during mdadm --grow: without this
>> patch, blkdiscard hangs in bio_await() and remains in uninterruptible
>> sleep after md reports "reshape done"; with this patch it returns
>> -EAGAIN instead.
>>
>> Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
>> ---
>> drivers/md/raid5.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
>> index ffb5fcde54a9..4c3b42b2af85 100644
>> --- a/drivers/md/raid5.c
>> +++ b/drivers/md/raid5.c
>> @@ -5722,9 +5722,11 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
>> if (WARN_ON_ONCE(bi->bi_opf & REQ_NOWAIT))
>> return;
>
>As nowait will be removed soon, I'm fine leaving it here.
>
>Reviewed-by: Yu Kuai <yukuai@fygo.io>
>
>>
>> - if (mddev->reshape_position != MaxSector)
>> + if (mddev->reshape_position != MaxSector) {
>> /* Skip discard while reshape is happening */
>> + bio_endio_status(bi, BLK_STS_AGAIN);
>> return;
>> + }
>>
>> if (!raid5_discard_limits(mddev, bi))
>> return;
>
>--
>Thanks,
>Kuai
Thanks for the review.
I'll leave the REQ_NOWAIT path unchanged and won't send a v2 for it.
Thanks,
Genjian
© 2016 - 2026 Red Hat, Inc.