2022-03-29 08:30:42 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Test that if a device is missing for a mounted filesystem, btrfs fi show will
|
|
|
|
# show which device exactly is missing.
|
|
|
|
|
2023-04-19 15:08:41 +00:00
|
|
|
source "$TEST_TOP/common" || exit
|
2022-03-29 08:30:42 +00:00
|
|
|
|
|
|
|
check_prereq mkfs.btrfs
|
|
|
|
check_prereq btrfs
|
|
|
|
|
|
|
|
setup_root_helper
|
|
|
|
setup_loopdevs 2
|
|
|
|
prepare_loopdevs
|
|
|
|
|
|
|
|
dev1=${loopdevs[1]}
|
|
|
|
dev2=${loopdevs[2]}
|
|
|
|
|
|
|
|
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -d raid1 "${loopdevs[@]}"
|
|
|
|
|
|
|
|
# Move the device, changing its path, simulating the device being missing
|
|
|
|
run_check $SUDO_HELPER mv "$dev2" /dev/loop-non-existent
|
|
|
|
|
|
|
|
run_check $SUDO_HELPER mount -o degraded $dev1 $TEST_MNT
|
|
|
|
|
|
|
|
if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT" | \
|
2023-02-13 05:26:33 +00:00
|
|
|
grep -q -e "devid[[:space:]]\+2.*MISSING"; then
|
2022-03-29 08:30:42 +00:00
|
|
|
|
|
|
|
_fail "didn't find exact missing device"
|
|
|
|
fi
|
|
|
|
|
|
|
|
run_check $SUDO_HELPER mv /dev/loop-non-existent "$dev2"
|
|
|
|
|
|
|
|
run_check $SUDO_HELPER umount "$TEST_MNT"
|
|
|
|
|
|
|
|
cleanup_loopdevs
|