Linux RAID subsystem development
 help / color / mirror / Atom feed
* [REGRESSION] md/raid10: far-layout member left with stale data after bitmap re-add (6.11+, 6.12.y, 6.18.y)
@ 2026-11-30 19:31 Eric Hagberg
  2026-11-30 19:48 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Hagberg @ 2026-11-30 19:31 UTC (permalink / raw)
  To: linux-raid, Song Liu, Yu Kuai; +Cc: Li Nan, Xiao Ni, stable, regressions

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30 19:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 19:31 [REGRESSION] md/raid10: far-layout member left with stale data after bitmap re-add (6.11+, 6.12.y, 6.18.y) Eric Hagberg
2026-11-30 19:48 ` sashiko-bot

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