Skip to content

Commit 4149678

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) (cherry picked from commit 0e46897)
1 parent 566e276 commit 4149678

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
@@ -577,9 +577,10 @@ EOF
577577
for ((i = 0; i < ${#devices[@]}; i++)); do
578578
# Intentionally use weaker cipher-related settings, since we don't care
579579
# about security here as it's a throwaway LUKS partition
580-
cryptsetup luksFormat -q \
581-
--use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \
582-
--uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile
580+
udevadm lock --device="${devices[$i]}" \
581+
cryptsetup luksFormat -q \
582+
--use-urandom --pbkdf pbkdf2 --pbkdf-force-iterations 1000 \
583+
--uuid "deadbeef-dead-dead-beef-11111111111$i" --label "encdisk$i" "${devices[$i]}" /etc/btrfs_keyfile
583584
udevadm wait --settle --timeout=30 "/dev/disk/by-uuid/deadbeef-dead-dead-beef-11111111111$i" "/dev/disk/by-label/encdisk$i"
584585
# Add the device into /etc/crypttab, reload systemd, and then activate
585586
# the device so we can create a filesystem on it later

0 commit comments

Comments
 (0)