btrfs-progs: tests: add test case for degraded raid5

The new test case will make sure btrfs check is fine checking a degraded
raid5 filesystem.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2022-11-13 14:32:39 +08:00 committed by David Sterba
parent 2aa4085bf7
commit fbb1170111
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#!/bin/bash
#
# Make sure "btrfs check" can handle degraded raid5.
#
source "$TEST_TOP/common"
check_prereq btrfs
check_prereq mkfs.btrfs
check_global_prereq losetup
check_global_prereq wipefs
setup_loopdevs 3
prepare_loopdevs
dev1=${loopdevs[1]}
dev2=${loopdevs[2]}
dev3=${loopdevs[3]}
setup_root_helper
# Run 1: victim is dev1
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}"
run_check $SUDO_HELPER wipefs -fa $dev1
run_check $SUDO_HELPER "$TOP/btrfs" check $dev2
# Run 2: victim is dev2
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}"
run_check $SUDO_HELPER wipefs -fa $dev2
run_check $SUDO_HELPER "$TOP/btrfs" check $dev3
# Run 3: victim is dev3
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m raid5 -d raid5 "${loopdevs[@]}"
run_check $SUDO_HELPER wipefs -fa $dev3
run_check $SUDO_HELPER "$TOP/btrfs" check $dev1
cleanup_loopdevs