Blob Blame History Raw
From 8134db6c335b28b6bd58bac4ef4c2236cc9ea06a Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@hoyer.xyz>
Date: Tue, 19 Dec 2017 15:43:58 +0100
Subject: [PATCH] Merge pull request #321 from danimo/multipath-fixes

SUSE fixes for 90multipath
---
 modules.d/90multipath/module-setup.sh            | 1 +
 modules.d/90multipath/multipath-shutdown.sh      | 7 +++++++
 modules.d/90multipath/multipathd-needshutdown.sh | 9 +++++----
 modules.d/90multipath/multipathd.service         | 5 ++++-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
index 0a680b17..983f6f24 100755
--- a/modules.d/90multipath/module-setup.sh
+++ b/modules.d/90multipath/module-setup.sh
@@ -89,6 +89,7 @@ install() {
     fi
 
     inst_hook cleanup   80 "$moddir/multipathd-needshutdown.sh"
+    inst_hook shutdown  20 "$moddir/multipath-shutdown.sh"
 
     inst_rules 40-multipath.rules 56-multipath.rules \
 	62-multipath.rules 65-multipath.rules \
diff --git a/modules.d/90multipath/multipath-shutdown.sh b/modules.d/90multipath/multipath-shutdown.sh
new file mode 100755
index 00000000..47e9990c
--- /dev/null
+++ b/modules.d/90multipath/multipath-shutdown.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+for i in $(multipath -l -v1); do
+    if ! $(dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1') ; then
+        dmsetup message $i 0 fail_if_no_path
+    fi
+done
diff --git a/modules.d/90multipath/multipathd-needshutdown.sh b/modules.d/90multipath/multipathd-needshutdown.sh
index 214abd3a..ee9b69b4 100755
--- a/modules.d/90multipath/multipathd-needshutdown.sh
+++ b/modules.d/90multipath/multipathd-needshutdown.sh
@@ -1,7 +1,8 @@
 #!/bin/sh
 
-for i in /dev/mapper/mpath*; do
-    [ -b "$i" ] || continue
-    need_shutdown
-    break
+for i in $(multipath -l -v1); do
+    if $(dmsetup table $i | sed -n '/.*queue_if_no_path.*/q1') ; then
+        need_shutdown
+        break
+    fi
 done
diff --git a/modules.d/90multipath/multipathd.service b/modules.d/90multipath/multipathd.service
index b64b02cd..0554d954 100644
--- a/modules.d/90multipath/multipathd.service
+++ b/modules.d/90multipath/multipathd.service
@@ -1,12 +1,15 @@
 [Unit]
 Description=Device-Mapper Multipath Device Controller
 Before=iscsi.service iscsid.service lvm2-activation-early.service
+Wants=systemd-udev-trigger.service systemd-udev-settle.service local-fs-pre.target
+After=systemd-udev-trigger.service systemd-udev-settle.service
+Before=local-fs-pre.target
 DefaultDependencies=no
 Conflicts=shutdown.target
 ConditionKernelCommandLine=!nompath
 ConditionKernelCommandLine=!rd.multipath=0
 ConditionKernelCommandLine=!rd_NO_MULTIPATH
-ConditionPathExists=/etc/multipath.conf
+ConditionKernelCommandLine=!multipath=off
 
 [Service]
 Type=simple