From 005d2cc047ae5be8980209a051e2919d45281cad Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Tue, 8 Aug 2023 13:52:06 +0800 Subject: [PATCH] btrfs-progs: tests: mkfs/005: use udevadm settle to avoid false alerts [BUG] During my test runs of mkfs-tests, 005-long-device-name-for-ssd failed with the following error messages: ====== RUN CHECK dmsetup remove btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQPGc device-mapper: remove ioctl on btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQPGc failed: Device or resource busy Command failed. failed: dmsetup remove btrfs-test-with-very-long-name-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQPGc test failed for case 005-long-device-name-for-ssd [CAUSE] There seems to be a race between "btrfs inspect dump-super" and the dmsetup removal. [FIX] Add a "udevadm settle" before removing the dm devices. Also since we're here, use the same "udevadm settle" instead of the manual sleep to wait for the new dm device to show up. Reviewed-by: Josef Bacik Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- tests/mkfs-tests/005-long-device-name-for-ssd/test.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh b/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh index 208698dc..e484edbc 100755 --- a/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh +++ b/tests/mkfs-tests/005-long-device-name-for-ssd/test.sh @@ -4,6 +4,7 @@ source "$TEST_TOP/common" || exit check_prereq mkfs.btrfs +check_global_prereq udevadm check_dm_target_support linear setup_root_helper @@ -24,7 +25,7 @@ loopdev=`run_check_stdout $SUDO_HELPER losetup --find --show img` run_check $SUDO_HELPER dmsetup create "$dmname" --table "0 1048576 linear $loopdev 0" # Setting up the device may need some time to appear -sleep 5 +run_check $SUDO_HELPER udevadm settle if ! [ -b "$dmdev" ]; then _not_run "dm device created but not visible in /dev/mapper" fi @@ -43,6 +44,8 @@ run_check_stdout $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@" "$dmdev" | grep -q 'SSD detected:.*yes' || _fail 'SSD not detected' run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$dmdev" +run_check $SUDO_HELPER udevadm settle + # cleanup run_check $SUDO_HELPER dmsetup remove "$dmname" run_mayfail $SUDO_HELPER losetup -d "$loopdev"