On Wed, 22 Jun 2016 11:18:41 -0600 Andrew Patterson
<andrew.patter...@hpe.com> wrote:

I forgot to add the multipath-tools.default file in the patch. Here is
the revised patch.

-- 
Andrew Patterson
Hewlett-Packard Enterprise

commit 566cc94c2fbcf1c59e5d3f8c30fd08c567f8a382
Author: Andrew Patterson <andrew.patter...@hpe.com>
Date:   Wed Jun 22 10:46:50 2016 -0600

    Load common set of multipath-modules in initramfs, sysvinit, and systemd
    
    Use variables in /etc/default/multipath-tools to load a common set
    of multipath kernel modules and hardware handlers in the initramfs (for
    multipath-tools-boot) and sysvinit scripts and systemd service files.
    
    Closes: #827407

diff --git a/debian/extra/multipath-discover b/debian/extra/multipath-discover
new file mode 100755
index 0000000..89be2ab
--- /dev/null
+++ b/debian/extra/multipath-discover
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# This script is used to discover multipath devices at boot. It can be
+# called from both the init script as well as the native systemd
+# service.
+#
+
+if [ -f /etc/default/multipath-tools ]; then
+	. /etc/default/multipath-tools
+else
+	MULTIPATH_TOOLS_HW_HANDLERS=""
+	MULTIPATH_TOOLS_MODULES="dm-mod dm-multipath"
+fi
+
+/sbin/modprobe -qa ${MULTIPATH_TOOLS_HW_HANDLERS}
+/sbin/modprobe -qa ${MULTIPATH_TOOLS_MODULES}
diff --git a/debian/initramfs/hooks b/debian/initramfs/hooks
index 4b60873..94cb7e8 100644
--- a/debian/initramfs/hooks
+++ b/debian/initramfs/hooks
@@ -17,6 +17,13 @@ fi
 
 . /usr/share/initramfs-tools/hook-functions
 
+if [ -f /etc/default/multipath-tools ]; then
+    . /etc/default/multipath-tools
+else
+    MULTIPATH_TOOLS_HW_HANDLERS=""
+    MULTIPATH_TOOLS_MODULES="dm-mod dm-multipath"
+fi
+
 add_bindings()
 {
   if [ -r /etc/multipath/bindings ]; then
@@ -48,7 +55,12 @@ add_udev_rules
 [ -r /etc/multipath.conf ] && cp /etc/multipath.conf $DESTDIR/etc/
 add_bindings
 
-for x in dm-multipath dm-service-time dm-round-robin dm-emc; do
-	manual_add_modules ${x}
+for x in $MULTIPATH_TOOLS_HW_HANDLERS; do
+    manual_add_modules ${x}
+done
+for x in $MULTIPATH_TOOLS_MODULES; do
+    manual_add_modules ${x}
 done
+echo "MULTIPATH_TOOLS_HW_HANDLERS=\"$MULTIPATH_TOOLS_HW_HANDLERS\"" > $DESTDIR/etc/multipath-tools-boot.conf
+echo "MULTIPATH_TOOLS_MODULES=\"$MULTIPATH_TOOLS_MODULES\"" >> $DESTDIR/etc/multipath-tools-boot.conf
 
diff --git a/debian/initramfs/init-top b/debian/initramfs/init-top
index 51637e9..ad27e83 100644
--- a/debian/initramfs/init-top
+++ b/debian/initramfs/init-top
@@ -26,10 +26,15 @@ verbose()
 
 maybe_break pre-multipath
 VERBOSITY=0
-HW_HANDLERS=""
+
+if [ -f /etc/multipath-tools-boot.conf ]; then
+    . /etc/multipath-tools-boot.conf
+else
+    MULTIPATH_TOOLS_HW_HANDLERS=""
+fi
 
 verbose && log_begin_msg "Loading multipath hardware handlers"
-for module in ${HW_HANDLERS}; do
+for module in ${MULTIPATH_TOOLS_HW_HANDLERS}; do
   if modprobe --syslog "$module"; then
     verbose && log_success_msg "loaded module ${module}."
   else
diff --git a/debian/initramfs/local-top b/debian/initramfs/local-top
index 33a6a29..99e4222 100644
--- a/debian/initramfs/local-top
+++ b/debian/initramfs/local-top
@@ -26,14 +26,19 @@ verbose()
 
 maybe_break pre-multipath
 VERBOSITY=0
-MP_MODULES="dm-multipath dm-emc"
 
 if [ ! -e /sbin/multipath ]; then
 	exit 0
 fi
 
+if [ -f /etc/multipath-tools-boot.conf ]; then
+    . /etc/multipath-tools-boot.conf
+else
+    MULTIPATH_TOOLS_MODULES="dm-mod dm-multipath"
+fi
+
 verbose && log_begin_msg "Loading multipath modules"
-for module in ${MP_MODULES}; do
+for module in ${MULTIPATH_TOOLS_MODULES}; do
   if modprobe "$module"; then
     verbose && log_success_msg "loaded module ${module}."
   else
diff --git a/debian/multipath-tools-boot.init b/debian/multipath-tools-boot.init
index 4be4904..41c6d01 100755
--- a/debian/multipath-tools-boot.init
+++ b/debian/multipath-tools-boot.init
@@ -32,7 +32,7 @@ set -e
 case "$1" in
   start)
 	log_action_begin_msg "$DESC"
-	modprobe dm-multipath 2> /dev/null || true
+	/lib/multipath/multipath-discover 2> /dev/null || true
 	$DAEMON -v $VERBOSITY
 	log_action_end_msg $?
 	;;
diff --git a/debian/multipath-tools.default b/debian/multipath-tools.default
new file mode 100644
index 0000000..09bcb88
--- /dev/null
+++ b/debian/multipath-tools.default
@@ -0,0 +1,8 @@
+# defaults file for multipath-tools and multipath-tools-boot.
+
+# SCSI hardware handler kernel modules loaded at boot. These are loaded
+# before modules listed in MULTIPATH_TOOLS_MODULES.
+MULTIPATH_TOOLS_HW_HANDLERS="scsi_dh scsi_dh_alua scsi_dh_emc scsi_dh_rdac"
+
+# Multipath kernel modules loaded at boot.
+MULTIPATH_TOOLS_MODULES="dm-mod dm-multipath dm-round-robin dm-service-time"
diff --git a/debian/rules b/debian/rules
index 8645d20..b153e1f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -85,6 +85,9 @@ install-indep:
 	install -D -m 644 debian/multipath-tools-boot.lintian-overrides \
 	    debian/multipath-tools-boot/usr/share/lintian/overrides/multipath-tools-boot
 
+	# Boot scripts.
+	install -D -m 555 debian/extra/multipath-discover debian/multipath-tools/lib/multipath/multipath-discover
+
 
 install: install-indep
 	dh_testdir
diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service
index e3d6f91..98f3766 100644
--- a/multipathd/multipathd.service
+++ b/multipathd/multipathd.service
@@ -11,7 +11,8 @@ Conflicts=shutdown.target
 Type=notify
 NotifyAccess=main
 LimitCORE=infinity
-ExecStartPre=/sbin/modprobe -a scsi_dh_alua scsi_dh_emc scsi_dh_rdac dm-multipath
+EnvironmentFile=/etc/default/multipath-tools
+ExecStartPre=/lib/multipath/multipath-discover
 ExecStart=/sbin/multipathd -d -s
 ExecReload=/sbin/multipathd reconfigure
 

Reply via email to