Harald Hoyer 3610a1
From 8134db6c335b28b6bd58bac4ef4c2236cc9ea06a Mon Sep 17 00:00:00 2001
Harald Hoyer 3610a1
From: Harald Hoyer <harald@hoyer.xyz>
Harald Hoyer 3610a1
Date: Tue, 19 Dec 2017 15:43:58 +0100
Harald Hoyer 3610a1
Subject: [PATCH] Merge pull request #321 from danimo/multipath-fixes
Harald Hoyer 3610a1
Harald Hoyer 3610a1
SUSE fixes for 90multipath
Harald Hoyer 3610a1
---
Harald Hoyer 3610a1
 modules.d/90multipath/module-setup.sh            | 1 +
Harald Hoyer 3610a1
 modules.d/90multipath/multipath-shutdown.sh      | 7 +++++++
Harald Hoyer 3610a1
 modules.d/90multipath/multipathd-needshutdown.sh | 9 +++++----
Harald Hoyer 3610a1
 modules.d/90multipath/multipathd.service         | 5 ++++-
Harald Hoyer 3610a1
 4 files changed, 17 insertions(+), 5 deletions(-)
Harald Hoyer 3610a1
Harald Hoyer 3610a1
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
Harald Hoyer 3610a1
index 0a680b17..983f6f24 100755
Harald Hoyer 3610a1
--- a/modules.d/90multipath/module-setup.sh
Harald Hoyer 3610a1
+++ b/modules.d/90multipath/module-setup.sh
Harald Hoyer 3610a1
@@ -89,6 +89,7 @@ install() {
Harald Hoyer 3610a1
     fi
Harald Hoyer 3610a1
 
Harald Hoyer 3610a1
     inst_hook cleanup   80 "$moddir/multipathd-needshutdown.sh"
Harald Hoyer 3610a1
+    inst_hook shutdown  20 "$moddir/multipath-shutdown.sh"
Harald Hoyer 3610a1
 
Harald Hoyer 3610a1
     inst_rules 40-multipath.rules 56-multipath.rules \
Harald Hoyer 3610a1
 	62-multipath.rules 65-multipath.rules \
Harald Hoyer 3610a1
diff --git a/modules.d/90multipath/multipath-shutdown.sh b/modules.d/90multipath/multipath-shutdown.sh
Harald Hoyer 3610a1
new file mode 100755
Harald Hoyer 3610a1
index 00000000..47e9990c
Harald Hoyer 3610a1
--- /dev/null
Harald Hoyer 3610a1
+++ b/modules.d/90multipath/multipath-shutdown.sh
Harald Hoyer 3610a1
@@ -0,0 +1,7 @@
Harald Hoyer 3610a1
+#!/bin/bash
Harald Hoyer 3610a1
+
Harald Hoyer 3610a1
+for i in $(multipath -l -v1); do
Harald Hoyer 3610a1
+    if ! $(dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1') ; then
Harald Hoyer 3610a1
+        dmsetup message $i 0 fail_if_no_path
Harald Hoyer 3610a1
+    fi
Harald Hoyer 3610a1
+done
Harald Hoyer 3610a1
diff --git a/modules.d/90multipath/multipathd-needshutdown.sh b/modules.d/90multipath/multipathd-needshutdown.sh
Harald Hoyer 3610a1
index 214abd3a..ee9b69b4 100755
Harald Hoyer 3610a1
--- a/modules.d/90multipath/multipathd-needshutdown.sh
Harald Hoyer 3610a1
+++ b/modules.d/90multipath/multipathd-needshutdown.sh
Harald Hoyer 3610a1
@@ -1,7 +1,8 @@
Harald Hoyer 3610a1
 #!/bin/sh
Harald Hoyer 3610a1
 
Harald Hoyer 3610a1
-for i in /dev/mapper/mpath*; do
Harald Hoyer 3610a1
-    [ -b "$i" ] || continue
Harald Hoyer 3610a1
-    need_shutdown
Harald Hoyer 3610a1
-    break
Harald Hoyer 3610a1
+for i in $(multipath -l -v1); do
Harald Hoyer 3610a1
+    if $(dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1') ; then
Harald Hoyer 3610a1
+        need_shutdown
Harald Hoyer 3610a1
+        break
Harald Hoyer 3610a1
+    fi
Harald Hoyer 3610a1
 done
Harald Hoyer 3610a1
diff --git a/modules.d/90multipath/multipathd.service b/modules.d/90multipath/multipathd.service
Harald Hoyer 3610a1
index b64b02cd..0554d954 100644
Harald Hoyer 3610a1
--- a/modules.d/90multipath/multipathd.service
Harald Hoyer 3610a1
+++ b/modules.d/90multipath/multipathd.service
Harald Hoyer 3610a1
@@ -1,12 +1,15 @@
Harald Hoyer 3610a1
 [Unit]
Harald Hoyer 3610a1
 Description=Device-Mapper Multipath Device Controller
Harald Hoyer 3610a1
 Before=iscsi.service iscsid.service lvm2-activation-early.service
Harald Hoyer 3610a1
+Wants=systemd-udev-trigger.service systemd-udev-settle.service local-fs-pre.target
Harald Hoyer 3610a1
+After=systemd-udev-trigger.service systemd-udev-settle.service
Harald Hoyer 3610a1
+Before=local-fs-pre.target
Harald Hoyer 3610a1
 DefaultDependencies=no
Harald Hoyer 3610a1
 Conflicts=shutdown.target
Harald Hoyer 3610a1
 ConditionKernelCommandLine=!nompath
Harald Hoyer 3610a1
 ConditionKernelCommandLine=!rd.multipath=0
Harald Hoyer 3610a1
 ConditionKernelCommandLine=!rd_NO_MULTIPATH
Harald Hoyer 3610a1
-ConditionPathExists=/etc/multipath.conf
Harald Hoyer 3610a1
+ConditionKernelCommandLine=!multipath=off
Harald Hoyer 3610a1
 
Harald Hoyer 3610a1
 [Service]
Harald Hoyer 3610a1
 Type=simple
Harald Hoyer 3610a1