summaryrefslogtreecommitdiff
path: root/udev
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2013-10-22 14:03:53 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2013-10-22 14:22:40 +0200
commit3fee6610286f83737d193c9047e24e8d7c85d1ce (patch)
treeda55b30be08bb1ee3d5d9395b092cfa1ed207d18 /udev
parent0a48137d39c51163ee29608c8c7ccbeecb4a7815 (diff)
downloadlvm2-3fee6610286f83737d193c9047e24e8d7c85d1ce.tar.gz
udev+systemd: refine lvm2-pvscan@.service to better track device existence
When using ENV{SYSTEMD_WANTS}=lvm2-pvscan@... to instantiate a service for lvmetad scan when the new PV appears in the system, the service is started and executed. However, to track device removal, we need to bind it (the "BindsTo" systemd directive) to a certain .device systemd unit. In default systemd setup, the device is tracked by it's name and sysfs path (there's normally a sysfs path .device systemd unit for a device and then the device name .device unit as an alias for it). Neither of these two is useful for lvmetad update as we need to bind it to device's <major>:<minor> pair. The /dev/block/<major>:<minor> is the essential symlink under /dev that exists for each block device (created by default udev rules provided by udev directly). So let's use this as an alias for the device's .device unit as well by means of "ENV{SYSTEMD_ALIAS}" declaration within udev rules which systemd understands (this will create a new alias "dev-block-<major>:<minor>.device". Then we can easily bind the "dev-block-<major>:<minor>" device systemd unit with instantiated lvm2-pvscan@<major>:<minor>.service. So once the device is removed from the systemd, the lvm-pvscan@<major>:<minor>.service executes it's ExecStop action (which in turn notifies lvmetad about the device being gone). This completes the udev-systemd-lvmetad interaction then.
Diffstat (limited to 'udev')
-rw-r--r--udev/Makefile.in4
1 files changed, 3 insertions, 1 deletions
diff --git a/udev/Makefile.in b/udev/Makefile.in
index fdf43df5e..8f0dc8a78 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -47,7 +47,9 @@ BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\"
endif
ifeq ("@UDEV_SYSTEMD_BACKGROUND_JOBS@", "yes")
-PVSCAN_RULE=ENV{SYSTEMD_WANTS}=\"lvm2-pvscan@\$$devnode.service\"
+PVSCAN_RULE="ENV{SYSTEMD_ALIAS}=\"/dev/block/$$major:$$minor\" \
+ ENV{ID_MODEL}=\"LVM PV $$env{ID_FS_UUID_ENC} on /dev/$$name\" \
+ ENV{SYSTEMD_WANTS}=\"lvm2-pvscan@\$$devnode.service\""
else
PVSCAN_RULE=RUN\+\=\"$(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major \$$major --minor \$$minor\", ENV{LVM_SCANNED}=\"1\"
endif