Re: [PATCH] md/raid10: preserve recovery flags on reshape abort

From: yu kuai

Date: Fri Nov 20 2026 - 02:05:25 EST


Hi,

在 2026/11/10 13:44, Hristos Nenkov 写道:
> raid10_start_reshape() can fail while resizing a bitmap before it
> changes any recovery bits on its success path. Its abort path nevertheless
> clears the entire mddev->recovery bitmap.
>
> dm-raid keeps MD_RECOVERY_FROZEN set across suspend and resume. If RAID10
> reshape setup fails, raid_preresume() logs the failure and continues with
> resume. Clearing the bitmap removes MD_RECOVERY_FROZEN and makes
> raid_resume() hit its invariant warning.
>
> Do not clear mddev->recovery from the RAID10 abort path. The error paths
> reach abort before raid10_start_reshape() modifies the recovery bits, so
> there is no personality-owned recovery state to roll back there.
>
> Fixes: bb63a7019df9 ("md/raid10: resize bitmap when required during reshape.")
> Reported-by: syzbot+8b22a0459202f76b4096@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=8b22a0459202f76b4096
> Signed-off-by: Hristos Nenkov <nenkov2004@xxxxxxxxx>
> ---
> drivers/md/raid10.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 066c43154..1fd3f5f4f 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -4490,7 +4490,6 @@ static int raid10_start_reshape(struct mddev *mddev)
> return 0;
>
> abort:
> - mddev->recovery = 0;

This is not quite related to this patch, but take a look at rs_start_reshape(),
MD_RECOVERY_WAIT is set before calling pers->start_reshape(), and it's never
cleared from error path.

This should probably be fixed first, and then it's safe to remove the above line.

> spin_lock_irq(&conf->device_lock);
> conf->geo = conf->prev;
> mddev->raid_disks = conf->geo.raid_disks;
>
> base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9

--
Thanks,
Kuai