Skip to content

Commit ff6b934

Browse files
hailan94gregkh
authored andcommitted
md: wake raid456 reshape waiters before suspend
[ Upstream commit cf86bb5 ] During raid456 reshape, direct IO across the reshape position can sleep in raid5_make_request() waiting for reshape progress while still holding an active_io reference. If userspace then freezes reshape and writes md/suspend_lo or md/suspend_hi, mddev_suspend() kills active_io and waits for all in-flight IO to drain. This can deadlock: the IO needs reshape progress to continue, but the reshape thread is already frozen, so the active_io reference is never dropped and suspend never completes. raid5_prepare_suspend() already wakes wait_for_reshape for dm-raid. Do the same for normal md suspend when reshape is already interrupted, so waiting raid456 IO can abort, drop its reference, and let suspend finish. The mdadm test tests/25raid456-reshape-deadlock reproduces the hang. Fixes: 714d201 ("md: add new helpers to suspend/resume array") Link: https://lore.kernel.org/linux-raid/20260327140729.2030564-1-yukuai@fnnas.com/ Signed-off-by: Yu Kuai <yukuai@fnnas.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f8b799e commit ff6b934

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

drivers/md/md.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,17 @@ int mddev_suspend(struct mddev *mddev, bool interruptible)
486486
}
487487

488488
percpu_ref_kill(&mddev->active_io);
489+
490+
/*
491+
* RAID456 IO can sleep in wait_for_reshape while still holding an
492+
* active_io reference. If reshape is already interrupted or frozen,
493+
* wake those waiters so they can abort and drop the reference instead
494+
* of deadlocking suspend.
495+
*/
496+
if (mddev->pers && mddev->pers->prepare_suspend &&
497+
reshape_interrupted(mddev))
498+
mddev->pers->prepare_suspend(mddev);
499+
489500
if (interruptible)
490501
err = wait_event_interruptible(mddev->sb_wait,
491502
percpu_ref_is_zero(&mddev->active_io));

0 commit comments

Comments
 (0)