From bb6ce6b6a463d0d6d19d0b258725412fa16c02e9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 22 May 2024 05:35:55 +0900 Subject: [PATCH 1/2] Revert "test: wipe filesystem before moving to the next test case" This reverts commit 301d7ee6112c6f766ee63d1daed3cd9535a65053. This does not solve issue #32913. --- test/units/TEST-64-UDEV-STORAGE.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/units/TEST-64-UDEV-STORAGE.sh b/test/units/TEST-64-UDEV-STORAGE.sh index 087968f42d3d0..c97db41da69ce 100755 --- a/test/units/TEST-64-UDEV-STORAGE.sh +++ b/test/units/TEST-64-UDEV-STORAGE.sh @@ -772,8 +772,6 @@ EOF btrfs filesystem show helper_check_device_symlinks helper_check_device_units - wipefs -a -f "${devices[@]}" - udevadm wait --settle --timeout=30 --removed "/dev/disk/by-uuid/$uuid" "/dev/disk/by-label/$label" echo "Multiple devices: using LUKS encrypted disks, data: raid1, metadata: raid1, mixed mode" uuid="deadbeef-dead-dead-beef-000000000003" From be43c9b0295120e508de1afd739af6fb7603186a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 22 May 2024 05:24:05 +0900 Subject: [PATCH 2/2] test: lock device during running cryptsetup On running cryptsetup, udevd detects two inotify events for the underlying device. Running the test on enough fast host, the expected symlinks based on UUID and disk label are created by the second event. During processing a uevent for a device, udevd disables the inotify watch for the device. If the test runs on slow system, the second inotify event may comes during a udev worker processing the synthesized uevent triggered by the first inotify event. Hence, no synthesized uevent for the second inotify event will be generated, and the expected symlinks will be never created. To prevent the issue, we need to lock the device during cryptsetup command is running. Fixes #32913. --- test/units/TEST-64-UDEV-STORAGE.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/units/TEST-64-UDEV-STORAGE.sh b/test/units/TEST-64-UDEV-STORAGE.sh index c97db41da69ce..70d7296ef22db 100755 --- a/test/units/TEST-64-UDEV-STORAGE.sh +++ b/test/units/TEST-64-UDEV-STORAGE.sh @@ -787,9 +787,10 @@ EOF for ((i = 0; i < ${#devices[@]}; i++)); do # Intentionally use weaker cipher-related settings, since we don't care # about security here as it's a throwaway LUKS partition - cryptsetup luksFormat -q \ - --use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \ - --uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile + udevadm lock --device="${devices[$i]}" \ + cryptsetup luksFormat -q \ + --use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \ + --uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile udevadm wait --settle --timeout=30 "/dev/disk/by-uuid/deadbeef-dead-dead-beef-11111111111$i" "/dev/disk/by-label/encdisk$i" # Add the device into /etc/crypttab, reload systemd, and then activate # the device so we can create a filesystem on it later