From: Eric Hagberg <ehagberg@janestreet.com>
To: linux-raid@vger.kernel.org, Song Liu <song@kernel.org>,
Yu Kuai <yukuai@fygo.io>
Cc: Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
stable@vger.kernel.org, regressions@lists.linux.dev
Subject: [REGRESSION] md/raid10: far-layout member left with stale data after bitmap re-add (6.11+, 6.12.y, 6.18.y)
Date: Mon, 30 Nov 2026 14:31:23 -0500 [thread overview]
Message-ID: <20261130193139.1401044-1-ehagberg@janestreet.com> (raw)
Hi,
On 6.12.y and 6.18.y, re-adding a member to a RAID10 array with the far
layout and an internal bitmap can complete "successfully" ([UU]) while
the re-added member still holds stale data for regions written while it
was absent. 6.1.y is not affected. This was seen on 2-disk
far=2 arrays (NVMe, internal bitmap, 64 MiB bitmap chunk) after a member
dropped out and came back; filesystems on the arrays were corrupted and
"check" reported non-zero mismatch_cnt.
#regzbot introduced: bc49694a9e8f
Reproducer (loop devices, 2 x 16 GiB zero-filled sparse files):
mdadm --create /dev/md/r10 --run --assume-clean --metadata=1.2 \
--level=10 --raid-devices=2 --layout=f2 --chunk=512 \
--bitmap=internal --bitmap-chunk=65536 /dev/loopA /dev/loopB
mdadm /dev/md/r10 --fail /dev/loopB --remove /dev/loopB
# write a 64 MiB random payload with O_DIRECT to every third
# 64 MiB bitmap chunk (85 regions)
mdadm /dev/md/r10 --re-add /dev/loopB # bitmap-based recovery
mdadm --wait /dev/md/r10 # until [UU]
echo check > /sys/block/mdX/md/sync_action; mdadm --wait /dev/md/r10
cat /sys/block/mdX/md/mismatch_cnt
mdadm /dev/md/r10 --fail /dev/loopA --remove /dev/loopA
# read the 85 regions back (now served only by loopB) and compare
Results ("OK" = mismatch_cnt 0 and every region read back correctly from
the re-added member):
kernel far=2 near=2
6.1 OK OK
6.12 CORRUPTION OK
6.18 CORRUPTION OK
We have not yet tested 7.x. A full script is available on request.
Our analysis, which we would appreciate having checked:
Commit bc49694a9e8f ("md: pass in max_sectors for pers->sync_request()"),
merged in v6.11, removed the recomputation of max_sector at the
'skipped:' label in raid10_sync_request(). The giveup path still shrinks
max_sector to sector_nr + max_sync, advances sector_nr to it and jumps
back to the label, where "sector_nr >= max_sector" is now true. The
function then takes the end-of-sync branch and calls the bitmap's
close_sync(), which clears RESYNC on every bitmap chunk whose sync has
started, as if it had completed.
During a bitmap-based recovery, every region that is clean in the bitmap
takes the giveup path. With the far layout, the data covered by one
bitmap chunk is split between the first and second halves of the
recovering member. Once a clean region is skipped, chunks whose first
half has been recovered are treated as done, their second half is
skipped, and the member is marked In_sync with stale data. Near layouts
recover each bitmap chunk contiguously, which matches what we see.
In mainline, 7435b73f05fb ("md/raid10: cleanup skip handling in
raid10_sync_request"), in v7.0, removed the skip loop and carries
"Fixes: bc49694a9e8f", but has no Cc: stable and is not in 6.12.y or
6.18.y. It is patch 11 of a 12-patch series and appears to depend on
earlier patches in it (it stops checking rdev_set_badblocks() return
values, which relies on "md: mark rdev Faulty when badblocks setting
fails").
Questions:
1. Does this analysis look right to you?
2. What is the preferred fix for 6.12.y and 6.18.y: backporting
7435b73f05fb together with the patches it depends on, or a smaller
targeted fix?
As a starting point for discussion only (not a formal submission), the
minimal change we tried restores the pre-6.11 recomputation by resetting
max_sector to the caller's value at the label. With it, the reproducer
passes for both layouts on 6.12 and 6.18. We have since had
concerns raised about it internally and would value your view on
whether it is safe:
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3191,6 +3191,7 @@ static sector_t raid10_sync_request(stru
sector_t chunk_mask = conf->geo.chunk_mask;
int page_idx = 0;
int error_disk = -1;
+ sector_t orig_max_sector = max_sector;
/*
* Allow skipping a full rebuild for incremental assembly
@@ -3212,6 +3213,7 @@ static sector_t raid10_sync_request(stru
return 0;
skipped:
+ max_sector = orig_max_sector;
if (sector_nr >= max_sector) {
conf->cluster_sync_low = 0;
conf->cluster_sync_high = 0;
Thanks,
Eric Hagberg
next reply other threads:[~2026-11-30 19:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 19:31 Eric Hagberg [this message]
2026-11-30 19:48 ` [REGRESSION] md/raid10: far-layout member left with stale data after bitmap re-add (6.11+, 6.12.y, 6.18.y) sashiko-bot
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=20261130193139.1401044-1-ehagberg@janestreet.com \
--to=ehagberg@janestreet.com \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=regressions@lists.linux.dev \
--cc=song@kernel.org \
--cc=stable@vger.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