[PATCH 28/31] kpartx.rules: fix logic for adding partitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Based on code by Ben Marzinski, this patch updates kpartx.rules.

The main change is that the flags that determine whether scanning is now
possible are DM_NOSCAN and DM_SUSPENDED. This assumes that said flags
are set correctly by 11-dm-mpath.rules.

Note that kpartx can't just be run if DM_ACTIVATION=1; doing so we
would miss events caused e.g. by partition table editing. It's not
necessary to scan for certain events. This will be handled in another
patch.

Currently this works for multipath only, but code for other targets
could be added if desired.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 kpartx/kpartx.rules | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules
index 6c8f4d53..b8141141 100644
--- a/kpartx/kpartx.rules
+++ b/kpartx/kpartx.rules
@@ -52,12 +52,27 @@ ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", \
        SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"
 LABEL="symlink_end"
 
-# Create dm tables for partitions
-ENV{DM_ACTION}=="PATH_FAILED|PATH_REINSTATED", GOTO="kpartx_end"
-ENV{DM_NR_VALID_PATHS}=="0", GOTO="kpartx_end"
+# Create dm tables for partitions on multipath devices.
+ENV{DM_UUID}!="mpath-?*", GOTO="mpath_kpartx_end"
+
+# DM_SUBSYSTEM_UDEV_FLAG1 is the "skip_kpartx" flag.
+# For events not generated by libdevmapper, we need to fetch it from db.
 ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1"
-ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="kpartx_end"
-ENV{DM_STATE}!="SUSPENDED", ENV{DM_UUID}=="mpath-*", \
-	RUN+="/sbin/kpartx -un -p -part /dev/$name"
+ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="mpath_kpartx_end"
+
+# Don't run kpartx now if we know it will fail or hang.
+ENV{DM_SUSPENDED}=="1", GOTO="mpath_kpartx_end"
+ENV{DM_NOSCAN}=="1", GOTO="mpath_kpartx_end"
+
+# Run kpartx
+GOTO="run_kpartx"
+LABEL="mpath_kpartx_end"
+
+## Code for other subsystems (non-multipath) could be placed here ##
+
+GOTO="kpartx_end"
+
+LABEL="run_kpartx"
+RUN+="/sbin/kpartx -un -p -part /dev/$name"
 
 LABEL="kpartx_end"
-- 
2.14.0

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux