Skip to content

Commit 0e46897

Browse files
yuwatabluca
authored andcommitted
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. (cherry picked from commit be43c9b) (cherry picked from commit 640dbad) (cherry picked from commit b88915b)
1 parent 47e33ef commit 0e46897

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/units/testsuite-64.sh

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

0 commit comments

Comments
 (0)