From 85764f475f3b3abd956bf8eaeaa643b367676cf4 Mon Sep 17 00:00:00 2001 From: Genjian Zhang Date: Sun, 12 Jul 2026 00:13:26 +0800 Subject: [PATCH] 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 Reviewed-by: Yu Kuai Link: https://patch.msgid.link/20260711161326.962336-1-zhanggenjian@126.com Signed-off-by: Yu Kuai --- drivers/md/raid5.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 552624bbec91..e5348cebf12d 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -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,