Skip to content

Commit be43c9b

Browse files
committed
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.
1 parent bb6ce6b commit be43c9b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/units/TEST-64-UDEV-STORAGE.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,10 @@ EOF
787787
for ((i = 0; i < ${#devices[@]}; i++)); do
788788
# Intentionally use weaker cipher-related settings, since we don't care
789789
# about security here as it's a throwaway LUKS partition
790-
cryptsetup luksFormat -q \
791-
--use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \
792-
--uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile
790+
udevadm lock --device="${devices[$i]}" \
791+
cryptsetup luksFormat -q \
792+
--use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \
793+
--uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile
793794
udevadm wait --settle --timeout=30 "/dev/disk/by-uuid/deadbeef-dead-dead-beef-11111111111$i" "/dev/disk/by-label/encdisk$i"
794795
# Add the device into /etc/crypttab, reload systemd, and then activate
795796
# the device so we can create a filesystem on it later

0 commit comments

Comments
 (0)