btrfs-progs/tests/cli-tests/017-fi-show-missing/test.sh
David Sterba 1faaa874a1 btrfs-progs: ci: wait for loop devices before mount
Since a few days the CI started to fail randomly when there were loop
devices used in the tests. The mount fails because some device is
reported to be missing:

  $ losetup --show --find
  /dev/loop3
  ...

  $ mkfs ...
  ERROR: device scan failed on '/dev/loop3': No such file or directory
  ...

  $ mount
  mount: /home/runner/work/btrfs-progs/btrfs-progs/tests/mnt: wrong fs
  type, bad option, bad superblock on /dev/loop3, missing codepage or
  helper program, or other error.

  $ dmesg
  ...
  BTRFS error (device loop0): devid 3 uuid 11d9c345-9527-433e-a024-7102659fa0ee is missing
  BTRFS error (device loop0): failed to read the system array: -2
  BTRFS error (device loop0): open_ctree failed

This was reproducible in the "cli" tests, but also happened on a local
machine.

To fix that wait for all loop devices before mount, the command
'btrfs device ready' should block until that. The convenience helper
does that, for any standalone 'mount' used with loop devices this must
be done manually.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-11-03 18:04:37 +01:00

37 lines
886 B
Bash
Executable File

#!/bin/bash
#
# Test that if a device is missing for a mounted filesystem, btrfs fi show will
# show which device exactly is missing.
source "$TEST_TOP/common" || exit
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
cond_wait_for_loopdevs
run_check $SUDO_HELPER mount -o degraded $dev1 $TEST_MNT
if ! run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem show "$TEST_MNT" | \
grep -q -e "devid[[:space:]]\+2.*MISSING"; then
_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