Package: udev
Version: 247.3-6
Severity: important

Dear systemd/udev Maintainers,

I've noticed a race condition with udev symlink creation, that can
cause long delays when activating logical volumes in LVM. Steps to
reproduce the problem (needs root):

    # prepare
    truncate -s 1G test.img
    loop="$(losetup --show -f test.img)"
    echo "Loop device used: $loop"
    pvcreate "$loop"
    vgcreate vgtest "$loop"
    # create 50 LVs with an ext4 fs, all with same label
    # (increase the number to make the problem more sever)
    for i in `seq 0 49` ; do
      lvcreate -L 4M -n dummy-${i} vgtest
      mkfs.ext4 -L dummy /dev/vgtest/dummy-${i}
    done
    # set all LVs in vgtest as inactive
    vgchange -an vgtest

    # trigger the problem by activating all lvs with the same label at
    # once (run `journalctl -f` in a different shell to see log
    # messages)
    vgchange -ay vgtest
    # can be repeated by setting as inactive and then active again

    # cleanup
    vgchange -an vgtest
    losetup -d "$loop"
    rm test.img


Observe that the activation takes a very long time. The log is flodded
with messages like

dm-??: Failed to update device symlinks: Too many levels of symbolic links

The devices are opened only very slowly (observe by running
`ls /dev/vgtest` while the activation is in progress).  This has
rendered one of my systems unbootable (wait for one of the necessary
volumes times out during boot).

I've temporarily worked around the issue by disabling the "by-label"
symlinks in udev for device mapper devices:

    sed '/by-label/ s/^/#/' \
      /lib/udev/rules.d/60-persistent-storage-dm.rules \
      > /etc/udev/rules.d/60-persistent-storage-dm.rules
    udevadm control --reload

Notice how the activation now is very fast. To undo this workaround
remove /etc/udev/rules.d/60-persistent-storage-dm.rules and reload udev
rules again.

The same issue is *not* present in the udev version from buster
(241-7~deb10u8).

Thank you
Lukas Schwaighofer

Attachment: pgp7lJETh0lyP.pgp
Description: OpenPGP digital signature

Reply via email to