]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: add flag to allow disabling blkid probing
authorDarsey Litzenberger <dlitz@dlitz.net>
Mon, 11 Jul 2022 04:47:45 +0000 (21:47 -0700)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 14 Jul 2022 22:54:14 +0000 (07:54 +0900)
This can be useful for users of slow block devices.

For example, the persistent-storage rules are needed for USB floppy
drives be recognized by udisks2, but the extra blkid calls cause
thrashing for 25+ seconds after every disk change.

With this change, a user wishing to avoid the extra blkid invocation(s)
could create /etc/udev/rules.d/55-floppy-noprobe.rules as follows:

    # Don't probe PC floppy drives
    SUBSYSTEM=="block", KERNEL=="fd*", \
        ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"

    # Don't probe USB floppy drives
    SUBSYSTEM=="block", SUBSYSTEMS=="usb", \
        ATTRS{bInterfaceClass}=="08", ATTRS{bInterfaceSubClass}=="04", \
        ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}="1"

I didn't exclude floppies by default in this change, because floppy
devices are also emulated by some BIOSes/hypervisors in some cases, and
I don't know how many systems would fail to boot if /dev/disk/by-uuid/*
became unavailable for 'floppy disks' on those systems.

rules.d/60-persistent-storage.rules

index de0842820720ae10f54f15c66ab8c9f3367f1633..03f0a619dc4568e6bc234fb1048bf1cffbda7da9 100644 (file)
@@ -99,6 +99,9 @@ ENV{DEVTYPE}=="partition", ENV{ID_PATH_ATA_COMPAT}=="?*", SYMLINK+="disk/by-path
 KERNEL=="vd*[!0-9]", ENV{ID_PATH}=="pci-*", SYMLINK+="disk/by-path/virtio-$env{ID_PATH}"
 KERNEL=="vd*[0-9]", ENV{ID_PATH}=="pci-*", SYMLINK+="disk/by-path/virtio-$env{ID_PATH}-part%n"
 
+# allow admin to disable probing the filesystem for slow devices like floppy disk drives
+ENV{UDEV_DISABLE_PERSISTENT_STORAGE_BLKID_FLAG}=="1", GOTO="persistent_storage_blkid_probe_end"
+
 # probe filesystem metadata of optical drives which have a media inserted
 KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DATA}=="?*", ENV{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}=="?*", \
   IMPORT{builtin}="blkid --hint=session_offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET}"
@@ -109,6 +112,8 @@ KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}!="?*", ENV{ID_CDROM_MEDIA_TRACK_COUNT_DAT
 # probe filesystem metadata of disks
 KERNEL!="sr*|mmcblk[0-9]boot[0-9]", IMPORT{builtin}="blkid"
 
+LABEL="persistent_storage_blkid_probe_end"
+
 # by-label/by-uuid links (filesystem metadata)
 ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
 ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"