Open mwilck opened 5 months ago
Backport of systemd/systemd#31661.
There has been some confusion about the dependency between this change in the systemd udev rules and the related change in LVM2 2.03.24.
The systemd/udev change (this PR) is a fix for the logic with which systemd handles SYSTEMD_READY
for dm devices. It is independent of the changes in the device-mapper udev rules in LVM 2.03.24, and can be applied even if the latter are not applied.
OTOH, updating to LVM 2.03.24 without applying the changes from this PR comes with a slight regression risk as explained in this comment, because the updated device-mapper rules don't set DM_SUSPENDED
any more.
Therefore it's better and safer for everyone to backport this PR to the systemd-stable branches.
For information: @prajnoha, @bluca, @yuwata, @fbui, @bmarzins, @msekletar
The Arch Linux package has this since 255.6-2, as we ship lvm 2.03.24 already.
@eworm-de, thanks for the information. So you applied this patch downstream? Did you see any issues with either this or the new dm rule set?
Yes, I applied it downstream: https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/commit/e64d3b887242eebe9cd25223b6d68ae0a4f4bc0c
No issues for myself, and nothing has been reported. But as said: We have lvm 2.03.24, I can not tell what happens in combination with older versions.
No issues for myself, and nothing has been reported. But as said: We have lvm 2.03.24, I can not tell what happens in combination with older versions.
I am pretty positive that if there's any regeression risk, it would be caused by updating LVM without this patch, not vice-versa.
Device mapper devices are set up in multiple steps. The first step, which generates the initial "add" event, only creates an empty container, which is useless for higher layers. SYSTEMD_READY should be set to 0 on this event to avoid premature device activation.
The event that matters is the "activation" event: the first "change" event on which DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 is not set. When this event arrives, the device is ready for being scanned by blkid and similar tools, and for being activated by systemd.
Intermittent events with DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 should be ignored as far as systemd or higher-level block layers are concerned. Previous device properties and symlinks should be preserved: the device shouldn't be scanned or activated, but shouldn't be deactivated, either. In particular, SYSTEM_READY shouldn't be set to 0 if it wasn't set before, because that might cause mounted file systems to be unmounted. Such intermittent events may occur any time, before or after the "activation" event.
DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 can have multiple reasons. One possible reason is that the device is suspended. There are other reasons that depend on the device-mapper subsystem (LVM, multipath, dm-crypt, etc.).
The current systemd rule set
1) sets SYSTEMD_READY=0 if DM_UDEV_DISABLE_OTHER_RULES_FLAG is set in "add" events; 2) imports SYSTEMD_READY from the udev db if DM_SUSPENDED is set, and jumps to systemd_end; 3) sets SYSTEMD_READY=1, otherwise.
This logic has several flaws:
This patch fixes the logic as follows:
Fixes: b7cf1b6 ("udev: use SYSTEMD_READY to mask uninitialized DM devices") Fixes: 35a6750 ("rules: set SYSTEMD_READY=0 on DM_UDEV_DISABLE_OTHER_RULES_FLAG=1 only with ADD event (#2747)")
Signed-off-by: Martin Wilck mwilck@suse.com (cherry picked from commit c072860593329293e19580b337504adb52248462)