[PATCH RESEND 0/3] md/raid10: fix old data left by skipped and interrupted sync
From: Eric Hagberg
Date: Fri Dec 04 2026 - 12:46:38 EST
Hi,
Resending: my first send of this series reached only Song and Yu, not
the lists and other people on Cc. Nothing else has changed.
This follows up my report earlier in this thread. The three patches are
by Jason Chu; I am sending them on his behalf.
They fix cases in which raid10 with the classic write-intent bitmap
finishes a recovery or a resync while one copy still holds old data. md
reports the array as healthy afterwards. Each case is reproduced on
v7.4-rc5 with the shell script at the end of this mail (mdadm, loop
devices and sysfs; one test also uses dm-linear).
Patch 1: a bitmap based recovery that is not interrupted leaves old data
on the re-added member when the chunk size is below 64KiB. This is a
regression from 7435b73f05fb ("md/raid10: cleanup skip handling in
raid10_sync_request"), which dropped the limit of a skip to the range
that was examined.
Patch 2: a bitmap based recovery that is interrupted ("frozen" written
to sync_action, or the array stopped and reassembled) and then resumed
leaves old data on the re-added member. Reproduced with the far layout
and one returning member, and with the offset layout and two returning
members.
Patch 3: a resync that is interrupted just after it passed a bad block
near the end of a bitmap chunk forgets that the next bitmap chunk is
dirty. The restarted resync does not make the copies in that chunk
equal.
Results:
x86-64 KVM guest with two CPUs, 4KiB pages, mdadm 4.2, loop devices on
tmpfs. Each column is v7.4-rc5 with the patches up to that one applied.
The raid10 module was built from the patched raid10.c; the rest of the
kernel is the same in all columns. A kernel built without CONFIG_SMP
gave the same table.
v7.4-rc5 +1 +1,2 +1,2,3
far-recovery PASS PASS PASS PASS
recovery-small-chunk FAIL PASS PASS PASS
recovery-abort-far FAIL FAIL PASS PASS
recovery-abort-offset FAIL FAIL PASS PASS
resync-abort FAIL FAIL FAIL PASS
FAIL means that md reported the array idle and not degraded, a "check"
then counted mismatches, and the copies read from the member devices
were not the data that was written. The script prints the details. For
the last three tests Jason also ran each test with virtio disks and read
the same sectors from the disk images on the host after the guest had
exited. The host agreed with the guest on every copy.
The same script on bare metal (x86-64, a distribution userspace with
udev, mdadm 4.2), on 7.3.7 without and with the series:
7.3.7 +1,2,3
far-recovery PASS PASS
recovery-small-chunk FAIL PASS
recovery-abort-far FAIL PASS
recovery-abort-offset FAIL PASS
resync-abort FAIL PASS
For the recovery tests the failure counts on 7.3.7 are the same as on
v7.4-rc5.
On bare metal, with a separate script that interrupts recovery either
with "frozen" or with mdadm --stop and reassembly, the abort case that
patch 2 fixes also shows on 7.3.0 and on 6.1.193: in each case a
continued recovery is clean, and an interrupted and resumed one leaves
old copies on the returning member. Stopping and reassembling gives the
same result as "frozen", so an orderly reboot during recovery is enough.
"far-recovery" is the case that 7435b73f05fb fixed. It passes on
v7.4-rc5 and is in the script because it fails on the stable kernels
that have bc49694a9e8f ("md: pass in max_sectors for
pers->sync_request()") but not 7435b73f05fb. We see it on 6.12.117 and
6.18.65.
How this was found:
We run 6.12.y. A far layout array there returned old data after a
member was re-added. That is the "far-recovery" case, which I reported
earlier in this thread. While Jason prepared a backport of 7435b73f05fb
he tested the skip and abort paths of raid10_sync_request() and found
the three cases above. A backport that contains 7435b73f05fb and these
three patches is in testing on 6.12.117 and 6.18.65; we will send it to
stable@ once these patches are in mainline.
What was tested, and what was not:
- Live, v7.4-rc5: the table above. Nothing else was run on mainline.
The test kernels are minimal builds without KASAN, KCSAN or lockdep.
- Live, 6.12.117 with the backport: the same script, and a larger set
of QEMU runs with fault injection, power loss and KASAN, KCSAN and
lockdep kernels.
- The mainline patches are not the same text as the 6.12.y code. They
test for the classic bitmap with mddev->bitmap_id, patch 1 adds the
limit where 6.12.y still had it, and the abort branch is laid out
differently.
- Built for i386 and arm64 (raid10 built in) on 7.3.7 with the series,
and on 6.18.65 with the 6.18.y backport; arm64 also on 6.12.117 with
the 6.12.y backport. vmlinux links and there are no new warnings.
- Not tested: llbitmap, clustered md, dm-raid, reshape, and 64KiB
pages on mainline.
Known limits:
- After an interrupted recovery, a bitmap chunk whose copies were all
finished stays dirty and is copied again. After an interrupted
resync the bitmap is walked twice.
- The clean-bitmap return in the resync path can still move the cursor
past sync_max. No I/O is done past sync_max. Not changed here.
- From reading the code, not reproduced on mainline:
md_bitmap_get_counter() reports the span of a whole counter page for
a hijacked page, although each of its two counters covers half. The
walk added in patch 2 allows for that. The skip decisions in
raid10_sync_request() do not. Not changed here.
- raid1 and raid5 end an aborted sync in the same way (end_sync at
curr_resync, then close_sync). We did not examine or test them.
Questions:
1. Would you prefer the abort handling in md-bitmap.c, for example a
close_sync that takes the abort position and re-arms the chunks
from there on, as llbitmap_end_sync() already does? That could
serve raid1 and raid5 too. The patches keep it in raid10.c because
that is what we have tested.
2. For 6.12.y and 6.18.y: 7435b73f05fb alone makes the two
recovery-abort tests fail there, although they pass on 6.12.117 and
6.18.65 today. From reading the code, the early completion code in
those kernels happens to end the affected bitmap chunk as aborted.
We therefore plan to send one squashed patch for each to stable@.
If you or the stable maintainers prefer one patch for each mainline
commit, we can send that instead.
The analysis, the patches, their changelogs and the test script were
developed with AI coding assistants, then reviewed by Jason and me. The
results above come from the test runs described, not from the tools'
reasoning.
The patches are against md-7.5 (c526b7cd32f7) in the md tree and also
apply to v7.4-rc5.
Thanks,
Eric
The reproducer:
Run as root: sh md-raid10-sync-abort-repro.sh [test...]
It prints one RESULT line for each test and exits 1 if any test failed.
==== 8< ==== md-raid10-sync-abort-repro.sh ==== 8< ====
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Reproducers for lost write-intent bitmap state in md/raid10.
#
# Run as root:
#
# sh md-raid10-sync-abort-repro.sh [TEST...]
#
# TEST is one or more of:
#
# far-recovery bitmap recovery, far layout
# recovery-small-chunk bitmap recovery, 4 KiB chunks
# recovery-abort-far interrupted bitmap recovery, far layout,
# one returning member
# recovery-abort-offset interrupted bitmap recovery, offset layout,
# two returning members
# resync-abort interrupted resync with one bad block
# (needs dmsetup and dm-linear)
#
# With no argument, all five run. Each test prints one line
#
# RESULT test=<name> kernel=<uname -r> verdict=PASS|FAIL ...
#
# and the script exits 1 if any test failed.
#
# PASS means that every checked copy is current after md reports the
# array as idle and not degraded. FAIL means that md reports a healthy
# array while a member holds old data (recovery tests), or while two
# copies still differ in a region that the bitmap had marked dirty
# (resync test).
#
# Requirements: a kernel with raid10 and loop support, mdadm, losetup,
# blockdev, dd, cmp, tr, head and sha256sum.
#
# The script uses md$MD_NUM (default 127), loop devices on files under
# $WORK (default: a new directory under /tmp), and device-mapper names
# r10repro-*. It removes them on exit. It needs about 150 MiB in $WORK.
#
# Optional: MEMBERS="/dev/x /dev/y /dev/z" uses these three block
# devices (each at least 64 MiB, contents destroyed) instead of loop
# devices.
set -eu
MD_NUM=${MD_NUM:-127}
MD=/dev/md$MD_NUM
md=/sys/block/md$MD_NUM/md
WORK=${WORK:-}
MEMBERS=${MEMBERS:-}
# As in mdadm's own test suite: do not wait for udev, do not start units.
export MDADM_NO_UDEV=${MDADM_NO_UDEV:-1}
export MDADM_NO_SYSTEMCTL=${MDADM_NO_SYSTEMCTL:-1}
own_work=0
made_node=0
loops=""
dms=""
failed=0
die() {
echo "ERROR: $*" >&2
exit 2
}
stop_array() {
if [ -e "$md" ]; then
mdadm --stop "$MD" >/dev/null 2>&1 || true
fi
}
release_members() {
stop_array
for d in $dms; do
dmsetup remove "$d" >/dev/null 2>&1 || true
done
dms=""
for l in $loops; do
losetup -d "$l" >/dev/null 2>&1 || true
done
loops=""
}
cleanup() {
release_members
if [ "$made_node" = 1 ]; then
rm -f "$MD"
fi
if [ "$own_work" = 1 ]; then
rm -rf "$WORK"
fi
}
trap cleanup EXIT
# make_members COUNT SIZE_MIB: set M0..M(COUNT-1) to zero-filled devices.
make_members() {
count=$1
size_mib=$2
i=0
if [ -n "$MEMBERS" ]; then
for dev in $MEMBERS; do
[ "$i" -lt "$count" ] || break
dd if=/dev/zero of="$dev" bs=1M count="$size_mib" \
conv=fsync 2>/dev/null
eval "M$i=$dev"
i=$((i + 1))
done
[ "$i" -eq "$count" ] || die "MEMBERS must name $count devices"
return
fi
while [ "$i" -lt "$count" ]; do
rm -f "$WORK/member$i"
dd if=/dev/zero of="$WORK/member$i" bs=1M count="$size_mib" \
2>/dev/null
l=$(losetup -f)
losetup "$l" "$WORK/member$i"
loops="$loops $l"
eval "M$i=$l"
i=$((i + 1))
done
}
# Put a dm-linear device on top of M$1, so that its I/O can be held with
# "dmsetup suspend".
wrap_dm() {
eval "under=\$M$1"
sectors=$(blockdev --getsz "$under")
name=r10repro-$1
echo "0 $sectors linear $under 0" | dmsetup create "$name"
dms="$dms $name"
eval "M$1=/dev/mapper/$name"
}
md_node() {
if [ -e "$md/array_state" ] &&
[ "$(cat "$md/array_state")" != clear ]; then
die "md$MD_NUM is in use; set MD_NUM"
fi
if [ ! -e "$MD" ]; then
mknod "$MD" b 9 "$MD_NUM"
made_node=1
fi
}
# Print the md sysfs directory of the member in slot $1.
slot_dir() {
for d in "$md"/dev-*; do
if [ "$(cat "$d/slot")" = "$1" ]; then
echo "$d"
return
fi
done
die "no member in slot $1"
}
# wait_for SECONDS COMMAND...: poll until COMMAND succeeds.
wait_for() {
limit=$(($1 * 5))
shift
n=0
until "$@"; do
n=$((n + 1))
if [ "$n" -ge "$limit" ]; then
cat /proc/mdstat >&2
die "timed out waiting for: $*"
fi
sleep 0.2
done
}
is_idle() {
[ "$(cat "$md/sync_action")" = idle ]
}
is_idle_and_complete() {
is_idle && [ "$(cat "$md/degraded")" = 0 ]
}
# paused_at ACTION SECTOR: the sync thread waits at sync_max.
paused_at() {
read -r completed _ < "$md/sync_completed" || return 1
[ "$completed" = "$2" ] && [ "$(cat "$md/sync_action")" = "$1" ]
}
# Run "check" and print the number of sectors md found different.
scrub() {
echo check > "$md/sync_action"
sleep 1
wait_for 300 is_idle
cat "$md/mismatch_cnt"
}
# Make later raw reads of member devices come from the devices, not from
# stale page cache.
drop_member_cache() {
sync
for dev in "$@"; do
blockdev --flushbufs "$dev" 2>/dev/null || true
done
echo 3 > /proc/sys/vm/drop_caches
}
# read_member DEV SECTOR COUNT FILE: 512-byte sectors, absolute on DEV.
read_member() {
dd if="$1" of="$4" bs=512 skip="$2" count="$3" 2>/dev/null
}
# check_copy TEST MEMBER_INDEX SECTOR COUNT WANT_FILE: read one copy from a
# member, print what was found, and succeed if it matches WANT_FILE.
check_copy() {
eval "dev=\$M$2"
read_member "$dev" "$3" "$4" "$WORK/got"
want=$(sha256sum < "$5" | cut -c1-16)
got=$(sha256sum < "$WORK/got" | cut -c1-16)
echo "COPY test=$1 member=$2 dev=$dev sector=$3 count=$4" \
"want=$want got=$got"
[ "$want" = "$got" ]
}
pattern() {
head -c "$2" /dev/zero | tr '\000' "$1"
}
report() {
name=$1
verdict=$2
shift 2
echo "RESULT test=$name kernel=$(uname -r) verdict=$verdict $*"
if [ "$verdict" != PASS ]; then
failed=$((failed + 1))
fi
}
# --------------------------------------------------------------------
# far-recovery
#
# A member leaves a two-member far-2 array, data is written, and the member
# is re-added. Recovery is not interrupted.
# --------------------------------------------------------------------
test_far_recovery() {
make_members 2 64
md_node
mdadm --create "$MD" --run --quiet --assume-clean --metadata=1.2 \
--level=10 --layout=f2 --raid-devices=2 --chunk=64 \
--bitmap=internal --bitmap-chunk=1M "$M0" "$M1"
wait_for 30 is_idle
mdadm "$MD" --quiet --fail "$M1"
wait_for 30 mdadm "$MD" --quiet --remove "$M1"
[ "$(cat "$md/degraded")" = 1 ] || die "array is not degraded"
# 1 MiB of 'N' at 5, 20, 35 and 50 MiB while member 1 is out.
pattern N 1048576 > "$WORK/new"
for mib in 5 20 35 50; do
dd if="$WORK/new" of="$MD" bs=1M seek="$mib" count=1 \
oflag=direct conv=notrunc 2>/dev/null
done
sync
mdadm "$MD" --quiet --re-add "$M1"
wait_for 120 is_idle_and_complete
mismatches=$(scrub)
# Read the array from member 1 alone.
mdadm --stop "$MD" >/dev/null 2>&1
drop_member_cache "$M0" "$M1"
mdadm --assemble --run --readonly --quiet "$MD" "$M1" 2>/dev/null
stale=0
for mib in 5 20 35 50; do
dd if="$MD" of="$WORK/got" bs=1M skip="$mib" count=1 \
2>/dev/null
cmp -s "$WORK/new" "$WORK/got" || stale=$((stale + 1))
done
if [ "$stale" = 0 ] && [ "$mismatches" = 0 ]; then
verdict=PASS
else
verdict=FAIL
fi
report far-recovery "$verdict" \
"stale_regions_on_readded_member=$stale/4" \
"mismatch_cnt=$mismatches"
}
# --------------------------------------------------------------------
# recovery-small-chunk
#
# Three-member near-2 array with 4 KiB chunks and 64 KiB bitmap chunks.
# Member 1 leaves, every second 64 KiB of the first 1 MiB is written, and
# member 1 is re-added. Recovery is not interrupted. A clean range that is
# skipped must not carry the cursor past chunks that were not examined.
# --------------------------------------------------------------------
test_recovery_small_chunk() {
make_members 3 40
md_node
mdadm --create "$MD" --run --quiet --assume-clean --metadata=1.2 \
--level=10 --layout=n2 --raid-devices=3 --chunk=4 \
--bitmap=internal --bitmap-chunk=64K --size=32768 \
"$M0" "$M1" "$M2"
wait_for 30 is_idle
mdadm "$MD" --quiet --fail "$M1"
wait_for 30 mdadm "$MD" --quiet --remove "$M1"
[ "$(cat "$md/degraded")" = 1 ] || die "array is not degraded"
pattern N 65536 > "$WORK/new"
for k in 1 3 5 7 9 11 13 15; do
dd if="$WORK/new" of="$MD" bs=65536 seek="$k" count=1 \
oflag=direct conv=notrunc 2>/dev/null
done
sync
mdadm "$MD" --quiet --re-add "$M1"
wait_for 120 is_idle_and_complete
mismatches=$(scrub)
# Fail member 0, so that every block that has a copy on member 1
# and member 0 is now read from member 1.
mdadm "$MD" --quiet --fail "$M0"
drop_member_cache "$MD"
stale=0
for k in 1 3 5 7 9 11 13 15; do
dd if="$MD" of="$WORK/got" bs=65536 skip="$k" count=1 \
iflag=direct 2>/dev/null
cmp -s "$WORK/new" "$WORK/got" || stale=$((stale + 1))
done
if [ "$stale" = 0 ] && [ "$mismatches" = 0 ]; then
verdict=PASS
else
verdict=FAIL
fi
report recovery-small-chunk "$verdict" \
"stale_regions_read_without_member0=$stale/8" \
"mismatch_cnt=$mismatches"
}
# --------------------------------------------------------------------
# recovery-abort-far
#
# Three-member far-2 array, 64 KiB chunks, 256 KiB bitmap chunks. Member 1
# leaves, two 64 KiB chunks are written, member 1 is re-added. Recovery
# pauses at sync_max = 256 sectors and is stopped there with "frozen", then
# resumed. The two far copies on member 1 are behind the checkpoint in
# bitmap terms but not yet copied.
# --------------------------------------------------------------------
test_recovery_abort_far() {
make_members 3 40
md_node
mdadm --create "$MD" --run --quiet --assume-clean --metadata=1.2 \
--level=10 --layout=f2 --raid-devices=3 --chunk=64 \
--bitmap=internal --bitmap-chunk=256K --size=32768 \
--data-offset=1M "$M0" "$M1" "$M2"
wait_for 30 is_idle
offset=$(cat "$(slot_dir 1)/offset")
# For far-2 the second copy starts this many sectors into each member.
stride=$(cat "$md/component_size")
mdadm "$MD" --quiet --fail "$M1"
wait_for 30 mdadm "$MD" --quiet --remove "$M1"
[ "$(cat "$md/degraded")" = 1 ] || die "array is not degraded"
pattern A 65536 > "$WORK/expect0"
pattern B 65536 > "$WORK/expect3"
dd if="$WORK/expect0" of="$MD" bs=65536 seek=0 count=1 \
oflag=direct conv=notrunc 2>/dev/null
dd if="$WORK/expect3" of="$MD" bs=65536 seek=3 count=1 \
oflag=direct conv=notrunc 2>/dev/null
sync
echo 256 > "$md/sync_max"
mdadm "$MD" --quiet --re-add "$M1"
wait_for 60 paused_at recover 256
echo frozen > "$md/sync_action"
echo max > "$md/sync_max"
echo recover > "$md/sync_action"
wait_for 120 is_idle_and_complete
mismatches=$(scrub)
mdadm --stop "$MD" >/dev/null 2>&1
drop_member_cache "$M0" "$M1" "$M2"
stale=0
for i in 0 3; do
sector=$((offset + stride + (i / 3) * 128))
check_copy recovery-abort-far 1 "$sector" 128 \
"$WORK/expect$i" || stale=$((stale + 1))
done
if [ "$stale" = 0 ] && [ "$mismatches" = 0 ]; then
verdict=PASS
else
verdict=FAIL
fi
report recovery-abort-far "$verdict" \
"stale_copies_on_readded_member=$stale/2" \
"mismatch_cnt=$mismatches"
}
# --------------------------------------------------------------------
# recovery-abort-offset
#
# Three-member offset-3 array, 64 KiB chunks, 32 KiB bitmap chunks. Members
# 0 and 1 leave, two 32 KiB blocks are written, both members are re-added.
# Recovery is stopped at sync_max = 256 sectors and resumed. A bitmap chunk
# started for one returning member still has a copy outstanding on the
# other.
# --------------------------------------------------------------------
test_recovery_abort_offset() {
make_members 3 40
md_node
mdadm --create "$MD" --run --quiet --assume-clean --metadata=1.2 \
--level=10 --layout=o3 --raid-devices=3 --chunk=64 \
--bitmap=internal --bitmap-chunk=32K --size=32768 \
--data-offset=1M "$M0" "$M1" "$M2"
wait_for 30 is_idle
offset=$(cat "$(slot_dir 1)/offset")
echo frozen > "$md/sync_action"
mdadm "$MD" --quiet --fail "$M0"
wait_for 30 mdadm "$MD" --quiet --remove "$M0"
mdadm "$MD" --quiet --fail "$M1"
wait_for 30 mdadm "$MD" --quiet --remove "$M1"
[ "$(cat "$md/degraded")" = 2 ] || die "array is not doubly degraded"
pattern A 32768 > "$WORK/expect0"
pattern B 32768 > "$WORK/expect3"
dd if="$WORK/expect0" of="$MD" bs=32768 seek=0 count=1 \
oflag=direct conv=notrunc 2>/dev/null
dd if="$WORK/expect3" of="$MD" bs=32768 seek=3 count=1 \
oflag=direct conv=notrunc 2>/dev/null
sync
echo 256 > "$md/sync_max"
mdadm "$MD" --quiet --re-add "$M0"
mdadm "$MD" --quiet --re-add "$M1"
echo recover > "$md/sync_action"
wait_for 60 paused_at recover 256
echo frozen > "$md/sync_action"
echo max > "$md/sync_max"
echo recover > "$md/sync_action"
wait_for 120 is_idle_and_complete
mismatches=$(scrub)
mdadm --stop "$MD" >/dev/null 2>&1
drop_member_cache "$M0" "$M1" "$M2"
stale=0
for v in 0 3; do
for i in 0 1 2; do
# Member sector of the copy of block $v on member $i.
if [ "$v" = 0 ]; then
p=$((128 * i))
else
p=$((64 + 128 * ((i + 2) % 3)))
fi
check_copy recovery-abort-offset "$i" $((offset + p)) \
64 "$WORK/expect$v" || stale=$((stale + 1))
done
done
if [ "$stale" = 0 ] && [ "$mismatches" = 0 ]; then
verdict=PASS
else
verdict=FAIL
fi
report recovery-abort-offset "$verdict" \
"stale_copies=$stale/6" "mismatch_cnt=$mismatches"
}
# --------------------------------------------------------------------
# resync-abort
#
# Two-member near-2 array, 4 KiB chunks, 1 MiB bitmap chunks (2048 sectors).
# Bitmap chunks 0 and 1 are dirty, as after an unclean shutdown. The two
# copies of sector 3048 (in bitmap chunk 1) differ. Member 0 has one bad
# block at sector 2043, five sectors before the end of bitmap chunk 0.
#
# The resync pauses at sync_max = 2040. It is then allowed to run to 2048
# while member 1 is suspended, so that it stops with its cursor at 2044:
#
# [2040, 2043) read submitted, held by the suspended member
# [2043, 2044) bad block on member 0, only one copy readable,
# skipped. This call asks the bitmap about the page
# that starts at 2043. The page crosses into bitmap
# chunk 1, which is marked in progress.
# 2044 md waits for the held read before it goes on
#
# "frozen" interrupts the resync there. The interrupted resync is then
# restarted and runs to the end.
# --------------------------------------------------------------------
test_resync_abort() {
command -v dmsetup >/dev/null 2>&1 || {
echo "SKIP test=resync-abort (no dmsetup)"
return
}
make_members 2 16
wrap_dm 0
wrap_dm 1
md_node
mdadm --create "$MD" --run --quiet --assume-clean --metadata=1.2 \
--level=10 --layout=n2 --raid-devices=2 --chunk=4 \
--bitmap=internal --bitmap-chunk=1M --size=4096 \
"$M0" "$M1"
wait_for 30 is_idle
offset=$(cat "$(slot_dir 0)/offset")
[ "$offset" = "$(cat "$(slot_dir 1)/offset")" ] ||
die "members have different data offsets"
[ "$(cat "$md/bitmap/chunksize")" = 1048576 ] ||
die "unexpected bitmap chunk size"
# Same data on both copies, then make sector 3048 differ on member 1,
# as a write interrupted by a crash would.
pattern A 4194304 > "$WORK/fill"
dd if="$WORK/fill" of="$MD" bs=1M count=4 oflag=direct 2>/dev/null
sync
mdadm --stop "$MD" >/dev/null 2>&1
pattern B 512 > "$WORK/torn"
dd if="$WORK/torn" of="$M1" bs=512 seek=$((offset + 3048)) count=1 \
conv=notrunc,fsync 2>/dev/null
drop_member_cache "$M0" "$M1"
# On a host with udev, the write above can make udev assemble the
# array again on its own. Wait for it and stop that array, so that
# the assembly below is the only one.
if command -v udevadm >/dev/null 2>&1; then
udevadm settle || true
fi
stop_array
mdadm --assemble --run --quiet "$MD" "$M0" "$M1"
wait_for 30 is_idle
echo frozen > "$md/sync_action"
echo "$((offset + 2043)) 1" > "$(slot_dir 0)/bad_blocks"
echo "0 1" > "$md/bitmap_set_bits"
echo 2040 > "$md/sync_max"
echo resync > "$md/sync_action"
wait_for 60 paused_at resync 2040
dmsetup suspend r10repro-1
echo 2048 > "$md/sync_max"
sleep 1
echo frozen > "$md/sync_action" &
sleep 1
dmsetup resume r10repro-1
wait
[ "$(cat "$md/sync_action")" = frozen ] || die "resync was not stopped"
# Where md recorded the interrupted resync as having got to.
stopped_at=$(cat "$md/resync_start")
echo max > "$md/sync_max"
echo resync > "$md/sync_action"
sleep 1
wait_for 120 is_idle
mismatches=$(scrub)
mdadm --stop "$MD" >/dev/null 2>&1
drop_member_cache "$M0" "$M1"
# The resync copies member 0 over member 1, so both must hold 'A'.
head -c 512 "$WORK/fill" > "$WORK/expect"
copies=equal
check_copy resync-abort 0 $((offset + 3048)) 1 "$WORK/expect" ||
copies=differ
check_copy resync-abort 1 $((offset + 3048)) 1 "$WORK/expect" ||
copies=differ
if [ "$copies" = equal ] && [ "$mismatches" = 0 ]; then
verdict=PASS
else
verdict=FAIL
fi
report resync-abort "$verdict" "stopped_at=$stopped_at" \
"copies_of_sector_3048=$copies" "mismatch_cnt=$mismatches"
}
run_test() {
case "$1" in
far-recovery) test_far_recovery ;;
recovery-small-chunk) test_recovery_small_chunk ;;
recovery-abort-far) test_recovery_abort_far ;;
recovery-abort-offset) test_recovery_abort_offset ;;
resync-abort) test_resync_abort ;;
*) die "unknown test $1" ;;
esac
release_members
}
[ "$(id -u)" = 0 ] || die "run as root"
if [ -z "$WORK" ]; then
WORK=$(mktemp -d /tmp/r10repro.XXXXXX)
own_work=1
fi
mkdir -p "$WORK"
echo "kernel: $(uname -r)"
echo "mdadm: $(mdadm --version 2>&1)"
[ $# -gt 0 ] ||
set -- far-recovery recovery-small-chunk recovery-abort-far \
recovery-abort-offset resync-abort
for t in "$@"; do
echo "--- $t"
run_test "$t"
done
if [ "$failed" = 0 ]; then
echo "All tests passed."
else
echo "$failed test(s) failed."
exit 1
fi
==== 8< ==== end of script ==== 8< ====
Jason Chu (3):
md/raid10: do not skip past the range that sync_request examined
md/raid10: re-arm in-progress bitmap chunks when recovery is
interrupted
md/raid10: keep look-ahead bitmap chunks when resync is interrupted
drivers/md/raid10.c | 89 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 85 insertions(+), 4 deletions(-)
--
2.43.7