mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] md: don't update curr_resync_completed when curr_resync is ACTIVE
@ 2026-12-04  0:03 Miroslav Cimerman
  0 siblings, 0 replies; only message in thread
From: Miroslav Cimerman @ 2026-12-04  0:03 UTC (permalink / raw)
  To: Song Liu, Yu Kuai
  Cc: Li Nan, Xiao Ni, Logan Gunthorpe, Jens Axboe, linux-raid, linux-kernel

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@vger.kernel.org # 7.0+
Signed-off-by: Miroslav Cimerman <mc@raidlab.org>
---
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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-04  0:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-04  0:03 [PATCH] md: don't update curr_resync_completed when curr_resync is ACTIVE Miroslav Cimerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®