From 158255383c02d3fb81c82fb9ec6fd36fb234f68e Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Thu, 13 Apr 2017 07:22:23 -0500
Subject: [PATCH 02/14] RH: fixup udev rules for redhat

The multipath rules need to run after scsi_id is run. This means moving
them after 60-persistent-storage.rules for redhat. Also, we don't
currently set up all the symlinks that SuSE does. If we want them, they
should be done in the device-mapper package, since they are for all
device-mapper devices. Redhat also uses a different naming scheme for
partitions than SuSE.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 Makefile.inc              |  2 +-
 kpartx/Makefile           | 14 +++++++-------
 multipath/Makefile        |  4 ++--
 multipath/multipath.rules |  3 ++-
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index 1815f9a..2591fa9 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -47,7 +47,7 @@ endif
 
 prefix		=
 exec_prefix	= $(prefix)
-bindir		= $(exec_prefix)/sbin
+bindir		= $(exec_prefix)/usr/sbin
 libudevdir	= $(prefix)/$(SYSTEMDPATH)/udev
 udevrulesdir	= $(libudevdir)/rules.d
 multipathdir	= $(TOPDIR)/libmultipath
diff --git a/kpartx/Makefile b/kpartx/Makefile
index 7b75032..bfa6fe8 100644
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -26,19 +26,19 @@ $(EXEC): $(OBJS)
 install: $(EXEC) $(EXEC).8
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
-	$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)
-	$(INSTALL_PROGRAM) -m 755 kpartx_id $(DESTDIR)$(libudevdir)
-	$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)/rules.d
-	$(INSTALL_PROGRAM) -m 644 kpartx.rules $(DESTDIR)$(libudevdir)/rules.d/66-kpartx.rules
+#	$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)
+#	$(INSTALL_PROGRAM) -m 755 kpartx_id $(DESTDIR)$(libudevdir)
+#	$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)/rules.d
+#	$(INSTALL_PROGRAM) -m 644 kpartx.rules $(DESTDIR)$(libudevdir)/rules.d/66-kpartx.rules
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir)
 
 uninstall:
 	$(RM) $(DESTDIR)$(bindir)/$(EXEC)
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz
-	$(RM) $(DESTDIR)$(libudevdir)/kpartx_id
-	$(RM) $(DESTDIR)$(libudevdir)/rules.d/66-kpartx.rules
-	$(RM) $(DESTDIR)$(libudevdir)/rules.d/67-kpartx-compat.rules
+#	$(RM) $(DESTDIR)$(libudevdir)/kpartx_id
+#	$(RM) $(DESTDIR)$(libudevdir)/rules.d/66-kpartx.rules
+#	$(RM) $(DESTDIR)$(libudevdir)/rules.d/67-kpartx-compat.rules
 
 clean:
 	$(RM) core *.o $(EXEC) *.gz
diff --git a/multipath/Makefile b/multipath/Makefile
index c85314e..1e9ee4b 100644
--- a/multipath/Makefile
+++ b/multipath/Makefile
@@ -24,7 +24,7 @@ install:
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir)
 	$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir)
-	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
+	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
@@ -33,7 +33,7 @@ install:
 uninstall:
 	$(RM) $(DESTDIR)$(bindir)/$(EXEC)
 	$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules
-	$(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
+	$(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz
 	$(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz
 
diff --git a/multipath/multipath.rules b/multipath/multipath.rules
index 616a04c..4d78b98 100644
--- a/multipath/multipath.rules
+++ b/multipath/multipath.rules
@@ -33,6 +33,7 @@ GOTO="end_mpath"
 
 LABEL="check_kpartx"
 
+ENV{DM_UUID}=="mpath-?*|part[0-9]*-mpath-?*", OPTIONS+="link_priority=10"
 IMPORT{db}="DM_MULTIPATH_NEED_KPARTX"
 ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1", IMPORT{db}="DM_SUBSYSTEM_UDEV_FLAG1"
 ENV{DM_SUBSYSTEM_UDEV_FLAG1}=="1", GOTO="end_mpath"
@@ -42,7 +43,7 @@ ENV{DM_ACTIVATION}=="1", ENV{DM_MULTIPATH_NEED_KPARTX}="1"
 ENV{DM_SUSPENDED}=="1", GOTO="end_mpath"
 ENV{DM_ACTION}=="PATH_FAILED", GOTO="end_mpath"
 ENV{DM_ACTIVATION}!="1", ENV{DM_MULTIPATH_NEED_KPARTX}!="1", GOTO="end_mpath"
-RUN+="/sbin/kpartx -un -p -part /dev/$name"
+RUN+="/sbin/kpartx -un /dev/$name"
 ENV{DM_MULTIPATH_NEED_KPARTX}=""
 
 LABEL="end_mpath"
-- 
2.8.1

