md/raid5: complete discard bios while reshape is active

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>
Reviewed-by: Yu Kuai <yukuai@fygo.io>
Link: https://patch.msgid.link/20260711161326.962336-1-zhanggenjian@126.com
Signed-off-by: Yu Kuai <yukuai@fygo.io>
This commit is contained in:
Genjian Zhang
2026-07-12 00:13:26 +08:00
committed by Yu Kuai
parent fe8d6b0187
commit 85764f475f

View File

@@ -5794,8 +5794,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
int stripe_sectors;
if (mddev->reshape_position != MaxSector)
/* Skip discard while reshape is happening */
return;
goto complete_again;
if (!raid5_discard_limits(mddev, bi))
return;
@@ -5882,6 +5881,11 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
}
bio_endio(bi);
return;
complete_again:
/* Skip discard while reshape is happening */
bio_endio_status(bi, BLK_STS_AGAIN);
}
static bool ahead_of_reshape(struct mddev *mddev, sector_t sector,