[lvm-devel] dev-mornfall-lvmcache - udev: also autoactivate on coldplug

Petr Rockai mornfall at fedoraproject.org
Wed Jun 5 12:01:08 UTC 2013

Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=764195207d4773cf6f1674a2fb16e9a0acda304a
Commit:        764195207d4773cf6f1674a2fb16e9a0acda304a
Parent:        2ccb9eb861c3b65ffc1aac024425e2cc10950077
Author:        Peter Rajnoha <prajnoha at redhat.com>
AuthorDate:    Fri Apr 19 12:17:53 2013 +0200
Committer:     Peter Rajnoha <prajnoha at redhat.com>
CommitterDate: Fri Apr 19 12:43:36 2013 +0200

udev: also autoactivate on coldplug

Commit 756bcabbfe297688ba240a880bc2b55265ad33f0 fixed autoactivation
to not trigger on each uevent for a PV that appeared in the system
most notably the events that are triggered artificially (udevadm
trigger or as the result of the WATCH udev rule being applied that
consequently generates CHANGE uevents). This fixed a situation in
which VGs/LVs were activated when they should not.

BUT we still need to care about the coldplug used at boot to
retrigger the ADD events - the "udevadm trigger --action=add"!

For non-DM-based PVs, this is already covered as for these we
run the autoactivation on ADD event only.

However, for DM-based PVs, we still need to run the
autoactivation even for the artificial ADD event, reusing
the udev DB content from previous proper CHANGE event that
came with the DM device activation.

Simply, this patch fixes a situation in which we run extra
"udevadm trigger --action=add" (or echo add > /sys/block/<dev>/uevent)
for DM-based PVs (cryptsetup devices, multipath devices, any
other DM devices...).

Without this patch, while using lvmetad + autoactivation,
any VG/LV that has a DM-based PV and for which we do not
call the activation directly, the VG/LV is not activated.

For example a VG with an LV with root FS on it which is directly
activated in initrd and then missing activation of the rest
of the LVs in the VG because of unhandled uevent retrigger on
boot after switching to root FS (the "coldplug").

(No WHATS_NEW here as this fixes the commit mentioned
above and which was not released yet.)
 udev/10-dm.rules.in           |    5 ++++-
 udev/69-dm-lvm-metad.rules.in |    1 +
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index cfee145..512d156 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -77,7 +77,10 @@ LABEL="dm_flags_done"
 # before (e.g. in initrd). If udev is used in initrd, we require the udev init
 # script to not remove the existing udev database so we can reuse the information
 # stored at the time of device activation in the initrd.
+ACTION!="add", GOTO="dm_no_coldplug"
 # "dm" sysfs subdirectory is available in newer versions of DM
 # only (kernels >= 2.6.29). We have to check for its existence
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index b16a27a..66c58b3 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -26,6 +26,7 @@ ACTION=="remove", GOTO="lvm_scan"
 KERNEL!="dm-[0-9]*", ACTION!="add", GOTO="lvm_end"
 # If the PV is a dm device, scan only after proper mapping activation (CHANGE event + DM_ACTIVATION=1)
+# or after a coldplug (event retrigger) with "add" event (ADD event + DM_ACTIVATION=1)
 KERNEL=="dm-[0-9]*", ENV{DM_ACTIVATION}!="1", GOTO="lvm_end"

More information about the lvm-devel mailing list