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

18971c
From 3d1bd59eb09780fe156bb24fc6709ce844f68052 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Tue, 25 Aug 2015 13:49:10 +0200
18971c
Subject: [PATCH] multipath: add hostonly multipath.conf
18971c
18971c
Resolves: rhbz#994702
18971c
---
18971c
 modules.d/90multipath/module-setup.sh | 43 ++++++++++++++++++++++-----
18971c
 1 file changed, 35 insertions(+), 8 deletions(-)
18971c
18971c
diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh
18971c
index acfc56f8..4971d18d 100755
18971c
--- a/modules.d/90multipath/module-setup.sh
18971c
+++ b/modules.d/90multipath/module-setup.sh
18971c
@@ -2,18 +2,29 @@
18971c
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
18971c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
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 `ls -1 /dev/mapper/mpath*`; do
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
     # if there's no multipath binary, no go.
18971c
     require_binaries multipath || return 1
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
     [[ $hostonly ]] || [[ $mount_needs ]] && {
18971c
         for_each_host_dev_and_slaves is_mpath || return 255
18971c
     }
18971c
@@ -68,7 +79,18 @@ installkernel() {
18971c
 }
18971c
 
18971c
 install() {
18971c
-    local _f
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
         kpartx \
18971c
@@ -82,6 +104,11 @@ 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/*"