On Thu, 16 Jun 2016 22:13:10 +0530 Ritesh Raj Sarraf <r...@debian.org> wrote:
> On Thu, 2016-06-16 at 10:20 -0600, Andrew Patterson wrote: > > > Yes. That'd 
> be good. Perhaps the module loading could be
delegated to a > > separate > > > shell script. Such a script can then
be invoked in ExecStartPre for systemd, > > and > > > for shell
initscripts we'll just have to source it into the main initscript. > > >
> Yes. Although it may take some work to get it into the initramfs. > >
> > A good example will be the open-iscsi package. The (co)maintainer
has some > pretty neat scripts on similar housekeeping work. > > > >Â >
> > Do you want to submit a patch for this ? > > >Â > > > > > > > I
would be happy too. Give me a couple of days. > > Thanks.

Here is the promised patch.

-- 
Andrew Patterson
Hewlett-Packard Enterprise

commit 916211466614fe267b02a1b940bc6bedc33479ec
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/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