Harald Hoyer 308914
From b8a92b715677d52dbc2b27a710b9816fd8b9a63b Mon Sep 17 00:00:00 2001
Harald Hoyer 308914
From: Ben Howard <ben.howard@redhat.com>
Harald Hoyer 308914
Date: Fri, 3 Apr 2020 13:32:44 -0600
Harald Hoyer 308914
Subject: [PATCH] multipath: add automatic configuration for multipath
Harald Hoyer 308914
Harald Hoyer 308914
Add support for 'rd.multipath=default' for using the default
Harald Hoyer 308914
configuration on boot. The intended purpose for this is to help support
Harald Hoyer 308914
ostree-based image boots from multipathed devices (such as Fedora and
Harald Hoyer 308914
Red Hat CoreOS).
Harald Hoyer 308914
---
Harald Hoyer 308914
 dracut.cmdline.7.asc                               |  3 +++
Harald Hoyer 308914
 modules.d/90multipath/module-setup.sh              |  7 +++++--
Harald Hoyer 308914
 modules.d/90multipath/multipathd-configure.service | 19 +++++++++++++++++++
Harald Hoyer 308914
 modules.d/90multipath/multipathd.sh                |  5 +++++
Harald Hoyer 308914
 4 files changed, 32 insertions(+), 2 deletions(-)
Harald Hoyer 308914
Harald Hoyer 308914
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
Harald Hoyer 308914
index 646f1f03..63074353 100644
Harald Hoyer 308914
--- a/dracut.cmdline.7.asc
Harald Hoyer 308914
+++ b/dracut.cmdline.7.asc
Harald Hoyer 308914
@@ -431,6 +431,9 @@ MULTIPATH
Harald Hoyer 308914
 **rd.multipath=0**::
Harald Hoyer 308914
    disable multipath detection
Harald Hoyer 308914
 
Harald Hoyer 308914
+**rd.multipath=default**::
Harald Hoyer 308914
+   use default multipath settings
Harald Hoyer 308914
+
Harald Hoyer 308914
 FIPS
Harald Hoyer 308914
 ~~~~
Harald Hoyer 308914
 **rd.fips**::
Harald Hoyer 308914
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
Harald Hoyer 308914
index 48a9d09a..2bb7444b 100755
Harald Hoyer 308914
--- a/modules.d/90multipath/module-setup.sh
Harald Hoyer 308914
+++ b/modules.d/90multipath/module-setup.sh
Harald Hoyer 308914
@@ -83,11 +83,12 @@ install() {
Harald Hoyer 308914
         dmsetup \
Harald Hoyer 308914
         kpartx \
Harald Hoyer 308914
         mpath_wait \
Harald Hoyer 308914
+        mpathconf \
Harald Hoyer 308914
+        mpathpersist \
Harald Hoyer 308914
         multipath  \
Harald Hoyer 308914
         multipathd \
Harald Hoyer 308914
-        mpathpersist \
Harald Hoyer 308914
-        xdrgetuid \
Harald Hoyer 308914
         xdrgetprio \
Harald Hoyer 308914
+        xdrgetuid \
Harald Hoyer 308914
         /etc/xdrdevices.conf \
Harald Hoyer 308914
         /etc/multipath.conf \
Harald Hoyer 308914
         /etc/multipath/* \
Harald Hoyer 308914
@@ -109,7 +110,9 @@ install() {
Harald Hoyer 308914
     fi
Harald Hoyer 308914
 
Harald Hoyer 308914
     if dracut_module_included "systemd"; then
Harald Hoyer 308914
+        inst_simple "${moddir}/multipathd-configure.service" "${systemdsystemunitdir}/multipathd-configure.service"
Harald Hoyer 308914
         inst_simple "${moddir}/multipathd.service" "${systemdsystemunitdir}/multipathd.service"
Harald Hoyer 308914
+        systemctl -q --root "$initdir" enable multipathd-configure.service
Harald Hoyer 308914
         systemctl -q --root "$initdir" enable multipathd.service
Harald Hoyer 308914
     else
Harald Hoyer 308914
         inst_hook pre-trigger 02 "$moddir/multipathd.sh"
Harald Hoyer 308914
diff --git a/modules.d/90multipath/multipathd-configure.service b/modules.d/90multipath/multipathd-configure.service
Harald Hoyer 308914
new file mode 100644
Harald Hoyer 308914
index 00000000..de690615
Harald Hoyer 308914
--- /dev/null
Harald Hoyer 308914
+++ b/modules.d/90multipath/multipathd-configure.service
Harald Hoyer 308914
@@ -0,0 +1,19 @@
Harald Hoyer 308914
+[Unit]
Harald Hoyer 308914
+Description=Device-Mapper Multipath Default Configuration
Harald Hoyer 308914
+Before=iscsi.service iscsid.service lvm2-activation-early.service
Harald Hoyer 308914
+Wants=systemd-udev-trigger.service systemd-udev-settle.service local-fs-pre.target
Harald Hoyer 308914
+After=systemd-udev-trigger.service systemd-udev-settle.service
Harald Hoyer 308914
+Before=local-fs-pre.target multipathd.service
Harald Hoyer 308914
+DefaultDependencies=no
Harald Hoyer 308914
+Conflicts=shutdown.target
Harald Hoyer 308914
+
Harald Hoyer 308914
+ConditionKernelCommandLine=rd.multipath=default
Harald Hoyer 308914
+ConditionPathExists=!/etc/multipath.conf
Harald Hoyer 308914
+
Harald Hoyer 308914
+[Service]
Harald Hoyer 308914
+Type=oneshot
Harald Hoyer 308914
+ExecStartPre=-/usr/bin/mkdir -p /etc/multipath/multipath.conf.d
Harald Hoyer 308914
+ExecStart=/usr/sbin/mpathconf --enable
Harald Hoyer 308914
+
Harald Hoyer 308914
+[Install]
Harald Hoyer 308914
+WantedBy=sysinit.target
Harald Hoyer 308914
diff --git a/modules.d/90multipath/multipathd.sh b/modules.d/90multipath/multipathd.sh
Harald Hoyer 308914
index 2c2dcc85..936c5dc7 100755
Harald Hoyer 308914
--- a/modules.d/90multipath/multipathd.sh
Harald Hoyer 308914
+++ b/modules.d/90multipath/multipathd.sh
Harald Hoyer 308914
@@ -1,5 +1,10 @@
Harald Hoyer 308914
 #!/bin/sh
Harald Hoyer 308914
 
Harald Hoyer 308914
+if [ "$(getarg rd.multipath)x" == "default" ] && [ ! -e /etc/multipath.conf ]; then
Harald Hoyer 308914
+    mkdir -p /etc/multipath/multipath.conf.d
Harald Hoyer 308914
+    mpathconf --enable
Harald Hoyer 308914
+fi
Harald Hoyer 308914
+
Harald Hoyer 308914
 if getargbool 1 rd.multipath -d -n rd_NO_MULTIPATH && [ -e /etc/multipath.conf ]; then
Harald Hoyer 308914
     modprobe dm-multipath
Harald Hoyer 308914
     multipathd -B || multipathd
Harald Hoyer 308914