1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

tests: correct checked devices

Fix the testing logic.
With raid5 device the layout of files on a filesystem does not define
which leg will actually contain the block we try to damage.
So test will now figure out which device has damaged block.

Use 'check' functionality and also drop unneeded random write as we
now can identify easily in other way.
This commit is contained in:
Zdenek Kabelac 2023-06-25 11:52:47 +02:00
parent 5848f75278
commit 04860b6324

View File

@ -43,12 +43,6 @@ _test1() {
mount "$DM_DEV_DIR/$vg/$lv1" $mnt mount "$DM_DEV_DIR/$vg/$lv1" $mnt
# we don't want fileA to be located too early in the fs,
# otherwise activating the LV will trigger the corruption
# to be found and corrected, leaving nothing for syncaction
# to find and correct.
dd if=/dev/urandom of=$mnt/rand16M bs=1M count=16
cp fileA $mnt cp fileA $mnt
cp fileB $mnt cp fileB $mnt
cp fileC $mnt cp fileC $mnt
@ -56,19 +50,30 @@ _test1() {
umount $mnt umount $mnt
lvchange -an $vg/$lv1 lvchange -an $vg/$lv1
aux corrupt_dev "$dev1" BBBBBBBBBBBBBBBBB BBBBBBBBCBBBBBBBB # Corrupting raid1 is simple - 1 leg needs to be modifed
# For raid5 corrupted block can be places on any of its leg.
for i in "$@" ; do
aux corrupt_dev "$i" BBBBBBBBBBBBBBBBB BBBBBBBBCBBBBBBBB
done
lvchange -ay $vg/$lv1 lvchange -ay $vg/$lv1
lvs -o integritymismatches $vg/${lv1}_rimage_0 |tee mismatch # so without synchecking the array - integrity doesn't know yet about failure
grep 0 mismatch check lv_field $vg/${lv1}_rimage_0 integritymismatches "0"
check lv_field $vg/${lv1}_rimage_1 integritymismatches "0"
[ $# -gt 2 ] && check lv_field $vg/${lv1}_rimage_2 integritymismatches "0"
lvchange --syncaction check $vg/$lv1 lvchange --syncaction check $vg/$lv1
aux wait_recalc $vg/$lv1 aux wait_recalc $vg/$lv1
lvs -o integritymismatches $vg/${lv1}_rimage_0 |tee mismatch # after synaction check - integrity should recognize faulty devices
not grep 0 mismatch baddev=0
for i in 0 1 2 ; do
[ "$i" -gt 1 ] && [ $# -lt 3 ] && continue # only raid5 has rimage_2
[ "$(get lv_field $vg/${lv1}_rimage_${i} integritymismatches)" = "0" ] || baddev=$(( baddev + 1 ))
done
[ "$baddev" -eq 1 ] || die "Unexpected number of integritymismatched devices ($baddev)!"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt mount "$DM_DEV_DIR/$vg/$lv1" $mnt
cmp -b $mnt/fileA fileA cmp -b $mnt/fileA fileA
@ -82,12 +87,6 @@ _test2() {
mount "$DM_DEV_DIR/$vg/$lv1" $mnt mount "$DM_DEV_DIR/$vg/$lv1" $mnt
# we don't want fileA to be located too early in the fs,
# otherwise activating the LV will trigger the corruption
# to be found and corrected, leaving nothing for syncaction
# to find and correct.
dd if=/dev/urandom of=$mnt/rand16M bs=1M count=16
cp fileA $mnt cp fileA $mnt
cp fileB $mnt cp fileB $mnt
cp fileC $mnt cp fileC $mnt
@ -104,19 +103,15 @@ _test2() {
lvchange -ay $vg/$lv1 lvchange -ay $vg/$lv1
lvs -o integritymismatches $vg/${lv1}_rimage_0 |tee mismatch check lv_field $vg/${lv1}_rimage_0 integritymismatches "0"
grep 0 mismatch check lv_field $vg/${lv1}_rimage_1 integritymismatches "0"
lvs -o integritymismatches $vg/${lv1}_rimage_1 |tee mismatch
grep 0 mismatch
lvchange --syncaction check $vg/$lv1 lvchange --syncaction check $vg/$lv1
aux wait_recalc $vg/$lv1 aux wait_recalc $vg/$lv1
lvs -o integritymismatches $vg/${lv1}_rimage_0 |tee mismatch not check lv_field $vg/${lv1}_rimage_0 integritymismatches "0"
not grep 0 mismatch not check lv_field $vg/${lv1}_rimage_1 integritymismatches "0"
lvs -o integritymismatches $vg/${lv1}_rimage_1 |tee mismatch
not grep 0 mismatch
mount "$DM_DEV_DIR/$vg/$lv1" $mnt mount "$DM_DEV_DIR/$vg/$lv1" $mnt
cmp -b $mnt/fileA fileA cmp -b $mnt/fileA fileA
@ -130,9 +125,8 @@ lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 6 $vg "$dev1" "$dev2"
aux wait_recalc $vg/${lv1}_rimage_0 aux wait_recalc $vg/${lv1}_rimage_0
aux wait_recalc $vg/${lv1}_rimage_1 aux wait_recalc $vg/${lv1}_rimage_1
aux wait_recalc $vg/$lv1 aux wait_recalc $vg/$lv1
_test1 _test1 "$dev1"
lvs -o integritymismatches $vg/$lv1 |tee mismatch not check $vg/$lv1 integritymismatches "0"
not grep 0 mismatch
lvchange -an $vg/$lv1 lvchange -an $vg/$lv1
lvconvert --raidintegrity n $vg/$lv1 lvconvert --raidintegrity n $vg/$lv1
lvremove $vg/$lv1 lvremove $vg/$lv1
@ -144,8 +138,7 @@ aux wait_recalc $vg/${lv1}_rimage_0
aux wait_recalc $vg/${lv1}_rimage_1 aux wait_recalc $vg/${lv1}_rimage_1
aux wait_recalc $vg/$lv1 aux wait_recalc $vg/$lv1
_test2 _test2
lvs -o integritymismatches $vg/$lv1 |tee mismatch not check $vg/$lv1 integritymismatches "0"
not grep 0 mismatch
lvchange -an $vg/$lv1 lvchange -an $vg/$lv1
lvconvert --raidintegrity n $vg/$lv1 lvconvert --raidintegrity n $vg/$lv1
lvremove $vg/$lv1 lvremove $vg/$lv1
@ -157,11 +150,9 @@ aux wait_recalc $vg/${lv1}_rimage_0
aux wait_recalc $vg/${lv1}_rimage_1 aux wait_recalc $vg/${lv1}_rimage_1
aux wait_recalc $vg/${lv1}_rimage_2 aux wait_recalc $vg/${lv1}_rimage_2
aux wait_recalc $vg/$lv1 aux wait_recalc $vg/$lv1
_test1 _test1 "$dev1" "$dev2" "$dev3"
lvs -o integritymismatches $vg/$lv1 |tee mismatch not check $vg/$lv1 integritymismatches "0"
not grep 0 mismatch
lvchange -an $vg/$lv1 lvchange -an $vg/$lv1
lvconvert --raidintegrity n $vg/$lv1 lvconvert --raidintegrity n $vg/$lv1
lvremove $vg/$lv1 lvremove $vg/$lv1
vgremove -ff $vg vgremove -ff $vg