[PATCH] md: don't update curr_resync_completed when curr_resync is ACTIVE

From: Miroslav Cimerman

Date: Thu Dec 03 2026 - 19:06:46 EST


MD_RESYNC_ACTIVE (3) in curr_resync marks a sync that has started but
has done nothing yet. If the sync is interrupted before the first
->sync_request() call, md_do_sync() takes this marker as a position
and stores it in curr_resync_completed. md_update_sb() then saves 3 as
recovery_offset of the new member, and the next recovery skips its
sectors 0-2.

Update curr_resync_completed only when curr_resync is above
MD_RESYNC_ACTIVE.

Found with FuzzyRAID, a fault injection tester for RAID.

Fixes: eac58d08d493 ("md: Use enum for overloaded magic numbers used by mddev->curr_resync")
Cc: stable@xxxxxxxxxxxxxxx # 7.0+
Signed-off-by: Miroslav Cimerman <mc@xxxxxxxxxxx>
---
7.0+ because cc0dab317acb made the bug reachable by removing the
MD_RECOVERY_INTR check.

Arrays that already saved 3 as recovery_offset are not repaired by this
patch.

Tested on md-7.5 with RAID1 on null_blk members, the recovery
interrupted by writing "frozen" to sync_action or by a member failure:
stale sectors 0-2 (512 B blocks) or failing reads (4 KiB blocks) on
stock, everything copied with the fix.

drivers/md/md.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index c71c3b043496..5c5d867c59ec 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -10060,7 +10060,7 @@ void md_do_sync(struct md_thread *thread)
wait_event(mddev->recovery_wait, !atomic_read(&mddev->recovery_active));

if (!test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
- mddev->curr_resync >= MD_RESYNC_ACTIVE) {
+ mddev->curr_resync > MD_RESYNC_ACTIVE) {
/* All sync IO completes after recovery_active becomes 0 */
mddev->curr_resync_completed = mddev->curr_resync;
sysfs_notify_dirent_safe(mddev->sysfs_completed);

base-commit: c526b7cd32f75fea6021ffdab287b81cf38ddeb7
--
2.53.0