Blame SOURCES/0511-add-90multipath-hostonly-module.patch

18971c
From 6ef3173e86c2be99b504f7c7a789dea5c0072f64 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Mon, 10 Jul 2017 13:28:40 +0200
18971c
Subject: [PATCH] add 90multipath-hostonly module
18971c
18971c
hardcoding the wwid of the drives in the initramfs causes problems
18971c
when the drives are cloned to a system with the same hardware, but
18971c
different disk wwid's
18971c
18971c
https://bugzilla.redhat.com/show_bug.cgi?id=1457311
18971c
18971c
Cherry-picked from: 5ce7cc7337a4c769b223152c083914f2052aa348
18971c
Resolves: #1457311
18971c
---
18971c
 .../90multipath-hostonly/module-setup.sh      | 53 +++++++++++++++++++
18971c
 modules.d/90multipath/module-setup.sh         | 26 ---------
18971c
 2 files changed, 53 insertions(+), 26 deletions(-)
18971c
 create mode 100755 modules.d/90multipath-hostonly/module-setup.sh
18971c
18971c
diff --git a/modules.d/90multipath-hostonly/module-setup.sh b/modules.d/90multipath-hostonly/module-setup.sh
18971c
new file mode 100755
18971c
index 00000000..88839033
18971c
--- /dev/null
18971c
+++ b/modules.d/90multipath-hostonly/module-setup.sh
18971c
@@ -0,0 +1,53 @@
18971c
+#!/bin/bash
18971c
+
18971c
+# called by dracut
18971c
+check() {
18971c
+    return 255
18971c
+}
18971c
+
18971c
+# called by dracut
18971c
+depends() {
18971c
+    echo multipath
18971c
+    return 0
18971c
+}
18971c
+
18971c
+# called by dracut
18971c
+install() {
18971c
+    local _f _allow
18971c
+
18971c
+    is_mpath() {
18971c
+        local _dev=$1
18971c
+        [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1
18971c
+        [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0
18971c
+        return 1
18971c
+    }
18971c
+
18971c
+    majmin_to_mpath_dev() {
18971c
+        local _dev
18971c
+        for i in /dev/mapper/*; do
18971c
+            [[ $i == /dev/mapper/control ]] && continue
18971c
+            _dev=$(get_maj_min $i)
18971c
+            if [ "$_dev" = "$1" ]; then
18971c
+                echo $i
18971c
+                return
18971c
+            fi
18971c
+        done
18971c
+    }
18971c
+
18971c
+    add_hostonly_mpath_conf() {
18971c
+        is_mpath $1 && {
18971c
+            local _dev
18971c
+
18971c
+            _dev=$(majmin_to_mpath_dev $1)
18971c
+            [ -z "$_dev" ] && return
18971c
+            strstr "$_allow" "$_dev" && return
18971c
+            _allow="$_allow --allow $_dev"
18971c
+        }
18971c
+    }
18971c
+
18971c
+    [[ $hostonly ]] && {
18971c
+        for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
18971c
+        [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
18971c
+    }
18971c
+}
18971c
+
18971c
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
18971c
index 3983b7b7..232ddcd8 100755
18971c
--- a/modules.d/90multipath/module-setup.sh
18971c
+++ b/modules.d/90multipath/module-setup.sh
18971c
@@ -9,17 +9,6 @@ is_mpath() {
18971c
     return 1
18971c
 }
18971c
 
18971c
-majmin_to_mpath_dev() {
18971c
-    local _dev
18971c
-    for i in /dev/mapper/*; do
18971c
-        [[ $i == /dev/mapper/control ]] && continue
18971c
-        _dev=$(get_maj_min $i)
18971c
-        if [ "$_dev" = "$1" ]; then
18971c
-            echo $i
18971c
-            return
18971c
-        fi
18971c
-    done
18971c
-}
18971c
 
18971c
 check() {
18971c
     local _rootdev
18971c
@@ -81,16 +70,6 @@ installkernel() {
18971c
 
18971c
 install() {
18971c
     local _f _allow
18971c
-    add_hostonly_mpath_conf() {
18971c
-        is_mpath $1 && {
18971c
-            local _dev
18971c
-
18971c
-            _dev=$(majmin_to_mpath_dev $1)
18971c
-            [ -z "$_dev" ] && return
18971c
-            strstr "$_allow" "$_dev" && return
18971c
-            _allow="$_allow --allow $_dev"
18971c
-        }
18971c
-    }
18971c
 
18971c
     inst_multiple -o  \
18971c
         dmsetup \
18971c
@@ -105,11 +84,6 @@ install() {
18971c
         /etc/multipath.conf \
18971c
         /etc/multipath/*
18971c
 
18971c
-    [[ $hostonly ]] && {
18971c
-        for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
18971c
-        [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
18971c
-    }
18971c
-
18971c
     inst $(command -v partx) /sbin/partx
18971c
 
18971c
     inst_libdir_file "libmultipath*" "multipath/*"