master - udev: keep systemd vars on change event in 69-dm-lvm-metad.rules for systemd reload
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7a7b8a7778aace88c967ee8285485c494ce1f3f8 Commit: 7a7b8a7778aace88c967ee8285485c494ce1f3f8 Parent: 99bfbbf229acf4548f1ffc06625f464dc0ae4ca4 Author: Martin Wilck <[email protected]> AuthorDate: Tue Apr 17 11:38:12 2018 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Tue Apr 17 11:38:12 2018 +0200
udev: keep systemd vars on change event in 69-dm-lvm-metad.rules for systemd reload
The current logic that avoids setting SYSTEMD_ALIAS and SYSTEMD_WANTS on "change" events is flawed in the default "systemd background job" configuration. For systemd, it's important that device properties don't change spuriously.
If an "add" event starts lvm2-pvscan at .service for a device, and a "change" event follows, removing SYSTEMD_ALIAS and SYSTEMD_WANTS from the udev db, information about unit dependencies between the device and the pvscan service can be lost in systemd, in particular if the daemon configuration is reloaded.
Steps to reproduce problem:
- create a device with an LVM PV
- remove device
- add device (generates "add" and "change" uevents for the device) (at this point SYSTEMD_ALIAS and SYSTEMD_WANTS are clear in udev db)
- systemctl daemon-reload
(systemd reloads udev db)
- vgchange -a n
- remove device
=> the lvm2-pvscan at .service for the device is still active although the device is gone.
- add device again
=> the PV is not detected, because systemd sees the lvm2-pvscan at .service as active and thus doesn't restart it.
The original purpose of this logic was to avoid volumes being scanned over and over again. With systemd background jobs, that isn't necessary, because systemd will not restart the job as long as it's active.
--- WHATS_NEW | 1 + udev/69-dm-lvm-metad.rules.in | 54 ++++++++++++++++++++++++++++++---------- udev/Makefile.in | 4 ++- 3 files changed, 44 insertions(+), 15 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.178 - ===================================== + Keep systemd vars on change event in 69-dm-lvm-metad.rules for systemd reload. Write systemd and non-systemd rule in 69-dm-lvm-metad.rules, GOTO active one. Add test for activation/volume_list (Sub)LV remnants. Disallow usage of cache format 2 with mq cache policy.
udev/69-dm-lvm-metad.rules.in +40 -14
81 lines not on this page · raw message
udev/Makefile.in +3 -1
@@ -48,12 +48,14 @@ endif ifeq ("@UDEV_SYSTEMD_BACKGROUND_JOBS@", "yes") PVSCAN_RULE=systemd_background +PVSCAN_ACTION=add|change else PVSCAN_RULE=direct_pvscan +PVSCAN_ACTION=add endif %.rules: $(srcdir)/%.rules.in - $(SED) -e "s+(DM_DIR)+$(DM_DIR)+;s+(BINDIR)+$(BINDIR)+;s+(BLKID_RULE)+$(BLKID_RULE)+;s+(PVSCAN_RULE)+$(PVSCAN_RULE)+;s+(DM_EXEC_RULE)+$(DM_EXEC_RULE)+;s+(DM_EXEC)+$(DM_EXEC)+;s+(LVM_EXEC_RULE)+$(LVM_EXEC_RULE)+;s+(LVM_EXEC)+$(LVM_EXEC)+;" $< >$@ + $(SED) -e "s+(DM_DIR)+$(DM_DIR)+;s+(BINDIR)+$(BINDIR)+;s+(BLKID_RULE)+$(BLKID_RULE)+;s+(PVSCAN_RULE)+$(PVSCAN_RULE)+;s+(PVSCAN_ACTION)+$(PVSCAN_ACTION)+;s+(DM_EXEC_RULE)+$(DM_EXEC_RULE)+;s+(DM_EXEC)+$(DM_EXEC)+;s+(LVM_EXEC_RULE)+$(LVM_EXEC_RULE)+;s+(LVM_EXEC)+$(LVM_EXEC)+;" $< >$@ %_install: %.rules $(INSTALL_DATA) -D $< $(udevdir)/$(<F)