[lvm2] Autoactivate VG/LV on coldplug of DM-based PVs at boot.
Peter Rajnoha
prajnoha at fedoraproject.org
Fri Apr 19 12:20:04 UTC 2013
commit 19cc44730ec91843a3dc002b27fd7432338c7822
Author: Peter Rajnoha <prajnoha at redhat.com>
Date: Fri Apr 19 14:19:55 2013 +0200
Autoactivate VG/LV on coldplug of DM-based PVs at boot.
lvm2-2_02_99-also-autoactivate-on-coldplug.patch | 73 ++++++++++++++++++++++
lvm2.spec | 7 ++-
2 files changed, 79 insertions(+), 1 deletions(-)
---
diff --git a/lvm2-2_02_99-also-autoactivate-on-coldplug.patch b/lvm2-2_02_99-also-autoactivate-on-coldplug.patch
new file mode 100644
index 0000000..c1ceda9
--- /dev/null
+++ b/lvm2-2_02_99-also-autoactivate-on-coldplug.patch
@@ -0,0 +1,73 @@
+commit 764195207d4773cf6f1674a2fb16e9a0acda304a
+Author: Peter Rajnoha <prajnoha at redhat.com>
+Date: Fri Apr 19 12:17:53 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 deletion(-)
+
+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", ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="dm_disable"
++ACTION!="add", GOTO="dm_no_coldplug"
++ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", GOTO="dm_disable"
++ENV{DM_ACTIVATION}="1"
++LABEL="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"
+
+ LABEL="lvm_scan"
diff --git a/lvm2.spec b/lvm2.spec
index be7ca70..0a98d12 100644
--- a/lvm2.spec
+++ b/lvm2.spec
@@ -37,7 +37,7 @@
Summary: Userland logical volume management tools
Name: lvm2
Version: 2.02.98
-Release: 6%{?dist}
+Release: 7%{?dist}
License: GPLv2
Group: System Environment/Base
URL: http://sources.redhat.com/lvm2
@@ -56,6 +56,7 @@ Patch10: lvm2-2_02_99-exit-pvscan-cache-immediately-if-cluster-locking-used-or-l
Patch11: lvm2-2_02_99-skip-mlocking-verctors-on-arm-arch.patch
Patch12: lvm2-2_02_99-fix-autoactivation-to-not-autoactivate-vg-lv-on-each-pv-change.patch
Patch13: lvm2-2_02_99-synchronize-with-udev-in-pvscan-cache-and-fix-dangling-udev_sync-cookies.patch
+Patch14: lvm2-2_02_99-also-autoactivate-on-coldplug.patch
BuildRequires: libselinux-devel >= %{libselinux_version}, libsepol-devel
BuildRequires: ncurses-devel
@@ -104,6 +105,7 @@ or more physical volumes and creating one or more logical volumes
%patch11 -p1 -b .arm_vectors
%patch12 -p1 -b .autoactivation
%patch13 -p1 -b .dangling_cookies
+%patch14 -p1 -b .coldplug
%build
%define _default_pid_dir /run
@@ -600,6 +602,9 @@ the device-mapper event library.
%{_libdir}/pkgconfig/devmapper-event.pc
%changelog
+* Fri Apr 19 2013 Peter Rajnoha <prajnoha at redhat.com> - 2.02.98-7
+- Autoactivate VG/LV on coldplug of DM-based PVs at boot.
+
* Tue Apr 09 2013 Peter Rajnoha <prajnoha at redhat.com> - 2.02.98-6
- Synchronize with udev in pvscan --cache and fix dangling udev_sync cookies.
- Fix autoactivation to not autoactivate VG/LV on each change of the PVs used.
More information about the scm-commits
mailing list