From 7ec5ce5673d82818448ac36def7e0c7f7ca44805 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 30 Oct 2023 13:31:23 +0900 Subject: [PATCH 1/2] udev: update devlink with the newer device node even when priority is equivalent Several udev rules depends on the previous behavior, i.e. that udev replaces the devlink with the newer device node when the priority is equivalent. Let's relax the optimization done by 331aa7aa15ee5dd12b369b276f575d521435eb52. Follow-up for 331aa7aa15ee5dd12b369b276f575d521435eb52. Note, the offending commit drops O(N) of file reads per uevent, and this commit does not change the computational order. So, hopefully the performance impact of this change is small enough. Fixes #28141. --- src/udev/udev-node.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 6ba38087dc..e12c26ce5a 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -467,13 +467,13 @@ static int link_update(sd_device *dev, const char *slink, bool add) { /* The devlink priority is downgraded. Another device may have a higher * priority now. Let's find the device node with the highest priority. */ } else { - if (current_prio >= prio) - /* The devlink with equal or higher priority already exists and is - * owned by another device. Hence, it is not necessary to recreate it. */ + if (current_prio > prio) + /* The devlink with a higher priority already exists and is owned by + * another device. Hence, it is not necessary to recreate it. */ return 0; - /* This device has a higher priority than the current. Let's create the - * devlink to our device node. */ + /* This device has the equal or a higher priority than the current. Let's + * create the devlink to our device node. */ return node_symlink(dev, NULL, slink); } From 4ef83d9c8848eb931e24efd7ee898d09f88e22d9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 30 Oct 2023 13:50:10 +0900 Subject: [PATCH 2/2] udev: revert workarounds for issues caused by the devlink creation optimization This reverts the following two commits: - "udev: decrease devlink priority for encrypted partitions" c4521fc17bb33d10bf5aca3f87f6a394dfecf423. - "udev: decrease devlink priority for iso disks" df1dccd25547b430258bd42ec60428fc9aff1370. These commits are workarounds for issues caused by 331aa7aa15ee5dd12b369b276f575d521435eb52. With the previous commit, these workarounds are not necessary anymore, as partitions are always processed later than their whole disk, and a decrypted volume is also processed later than its backing volume. --- rules.d/60-persistent-storage.rules.in | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/rules.d/60-persistent-storage.rules.in b/rules.d/60-persistent-storage.rules.in index 39a6555045..6787430208 100644 --- a/rules.d/60-persistent-storage.rules.in +++ b/rules.d/60-persistent-storage.rules.in @@ -134,17 +134,6 @@ KERNEL!="sr*|mmcblk[0-9]boot[0-9]", IMPORT{builtin}="blkid" LABEL="persistent_storage_blkid_probe_end" {% endif %} -# Decrease devlink priority for whole disk of ISO hybrid images, and make the -# priority for partitions in the image relatively higher. This is for the case -# that a disk and one of its partition have the same label or so. -# See issue #28468. -ENV{ID_FS_TYPE}=="iso9660", ENV{DEVTYPE}=="disk", OPTIONS+="link_priority=-10" - -# Decrease devlink priority for encrypted partitions, and make the priority for -# decrypted DM devices relatively higher. This is for the case that an encrypted -# partition and its decrypted DM device have the same label. -ENV{ID_FS_USAGE}=="crypto", OPTIONS+="link_priority=-10" - # 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}"