Skip to content

Commit 4b10a3b

Browse files
Li NanYu Kuai
authored andcommitted
md: ensure resync is prioritized over recovery
If a new disk is added during resync, the resync process is interrupted, and recovery is triggered, causing the previous resync to be lost. In reality, disk addition should not terminate resync, fix it. Steps to reproduce the issue: mdadm -CR /dev/md0 -l1 -n3 -x1 /dev/sd[abcd] mdadm --fail /dev/md0 /dev/sdc Fixes: 24dd469 ("[PATCH] md: allow a manual resync with md") Signed-off-by: Li Nan <linan122@huawei.com> Reviewed-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/linux-raid/20250213131530.3698600-1-linan666@huaweicloud.com Signed-off-by: Yu Kuai <yukuai3@huawei.com>
1 parent a052bfa commit 4b10a3b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/md/md.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9460,6 +9460,13 @@ static bool md_choose_sync_action(struct mddev *mddev, int *spares)
94609460
return true;
94619461
}
94629462

9463+
/* Check if resync is in progress. */
9464+
if (mddev->recovery_cp < MaxSector) {
9465+
set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
9466+
clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
9467+
return true;
9468+
}
9469+
94639470
/*
94649471
* Remove any failed drives, then add spares if possible. Spares are
94659472
* also removed and re-added, to allow the personality to fail the
@@ -9476,13 +9483,6 @@ static bool md_choose_sync_action(struct mddev *mddev, int *spares)
94769483
return true;
94779484
}
94789485

9479-
/* Check if recovery is in progress. */
9480-
if (mddev->recovery_cp < MaxSector) {
9481-
set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
9482-
clear_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
9483-
return true;
9484-
}
9485-
94869486
/* Delay to choose resync/check/repair in md_do_sync(). */
94879487
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
94889488
return true;

0 commit comments

Comments
 (0)