From: Miroslav Cimerman <mc@raidlab.org>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai@fygo.io>
Cc: Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
Logan Gunthorpe <logang@deltatee.com>,
Jens Axboe <axboe@kernel.dk>,
linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] md: don't update curr_resync_completed when curr_resync is ACTIVE
Date: Fri, 4 Dec 2026 00:03:39 +0000 [thread overview]
Message-ID: <20261204000339.1209921-1-mc@raidlab.org> (raw)
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
reply other threads:[~2026-12-04 0:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204000339.1209921-1-mc@raidlab.org \
--to=mc@raidlab.org \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=magiclinan@didiglobal.com \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox