Blame SOURCES/0327-multipath-add-hostonly-multipath.conf.patch

712866
From 3d1bd59eb09780fe156bb24fc6709ce844f68052 Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Tue, 25 Aug 2015 13:49:10 +0200
712866
Subject: [PATCH] multipath: add hostonly multipath.conf
712866
712866
Resolves: rhbz#994702
712866
---
712866
 modules.d/90multipath/module-setup.sh | 43 ++++++++++++++++++++++++++++-------
712866
 1 file changed, 35 insertions(+), 8 deletions(-)
712866
712866
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
5c6c2a
index acfc56f8..4971d18d 100755
712866
--- a/modules.d/90multipath/module-setup.sh
712866
+++ b/modules.d/90multipath/module-setup.sh
712866
@@ -2,18 +2,29 @@
712866
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
712866
 # ex: ts=8 sw=4 sts=4 et filetype=sh
712866
 
712866
+is_mpath() {
712866
+    local _dev=$1
712866
+    [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1
712866
+    [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0
712866
+    return 1
712866
+}
712866
+
712866
+majmin_to_mpath_dev() {
712866
+    local _dev
712866
+    for i in `ls -1 /dev/mapper/mpath*`; do
712866
+        dev=$(get_maj_min $i)
712866
+        if [ "$dev" = "$1" ]; then
712866
+            echo $i
712866
+            return
712866
+        fi
712866
+    done
712866
+}
712866
+
712866
 check() {
712866
     local _rootdev
712866
     # if there's no multipath binary, no go.
712866
     require_binaries multipath || return 1
712866
 
712866
-    is_mpath() {
712866
-        local _dev=$1
712866
-        [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1
712866
-        [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0
712866
-        return 1
712866
-    }
712866
-
712866
     [[ $hostonly ]] || [[ $mount_needs ]] && {
712866
         for_each_host_dev_and_slaves is_mpath || return 255
712866
     }
712866
@@ -68,7 +79,18 @@ installkernel() {
712866
 }
712866
 
712866
 install() {
712866
-    local _f
712866
+    local _f _allow
712866
+    add_hostonly_mpath_conf() {
712866
+        is_mpath $1 && {
712866
+            local _dev
712866
+
712866
+            _dev=$(majmin_to_mpath_dev $1)
712866
+            [ -z "$_dev" ] && return
712866
+            strstr "$_allow" "$_dev" && return
712866
+            _allow="$_allow --allow $_dev"
712866
+        }
712866
+    }
712866
+
712866
     inst_multiple -o  \
712866
         dmsetup \
712866
         kpartx \
712866
@@ -82,6 +104,11 @@ install() {
712866
         /etc/multipath.conf \
712866
         /etc/multipath/*
712866
 
712866
+    [[ $hostonly ]] && {
712866
+        for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
712866
+        [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
712866
+    }
712866
+
712866
     inst $(command -v partx) /sbin/partx
712866
 
712866
     inst_libdir_file "libmultipath*" "multipath/*"