From 61fdb5b2141d08b2ea4040d2681b4fa9b532c5ac Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 28 May 2024 11:51:48 +0900 Subject: [PATCH] test: wait for the kernel finishes to attach backing file to loop device Fixes #32680. --- test/units/TEST-74-AUX-UTILS.mount.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/units/TEST-74-AUX-UTILS.mount.sh b/test/units/TEST-74-AUX-UTILS.mount.sh index ba47b5384db..14253c358d1 100755 --- a/test/units/TEST-74-AUX-UTILS.mount.sh +++ b/test/units/TEST-74-AUX-UTILS.mount.sh @@ -159,7 +159,12 @@ timeout 60 bash -c "while [[ -e /sys/$LOOP_AUTO_DEVPATH/loop/backing_file ]]; do dd if=/dev/zero of="$WORK_DIR/owner-vfat.img" bs=1M count=16 mkfs.vfat -n owner-vfat "$WORK_DIR/owner-vfat.img" LOOP="$(losetup --show --find "$WORK_DIR/owner-vfat.img")" -udevadm wait --timeout 60 --settle "$LOOP" +# If the synthesized uevent triggered by inotify event has been processed earlier than the kernel finishes to +# attach the backing file, then SYSTEMD_READY=0 is set for the device. As a workaround, monitor sysattr +# and re-trigger uevent after that. +LOOP_DEVPATH=$(udevadm info --query property --property DEVPATH --value "$LOOP") +timeout 60 bash -c "until [[ -e /sys/$LOOP_DEVPATH/loop/backing_file ]]; do sleep 1; done" +udevadm trigger --settle "$LOOP" # Also wait for the .device unit for the loop device is active. Otherwise, the .device unit activation # that is triggered by the .mount unit introduced by systemd-mount below may time out. if ! timeout 60 bash -c "until systemctl is-active $LOOP; do sleep 1; done"; then