]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Merge 90-multipath-hostonly and 90-multipath
authorKairui Song <kasong@redhat.com>
Thu, 5 Jul 2018 08:20:04 +0000 (16:20 +0800)
committerHarald Hoyer <harald@hoyer.xyz>
Thu, 5 Jul 2018 11:17:19 +0000 (13:17 +0200)
This commit basically reverts 5ce7cc73

90-multipath-hostonly module was added in 5ce7cc73, because if hostonly
mode is enabled, multipath module will always hardcode wwids which
causes problems when the initramfs is cloned to another system with same
hardware.

Now with tri-state hostonly mode, the two modules could be merged and only
hardcode wwids when "strict" hostonly mode is enabled.

modules.d/90multipath-hostonly/module-setup.sh [deleted file]
modules.d/90multipath/module-setup.sh

diff --git a/modules.d/90multipath-hostonly/module-setup.sh b/modules.d/90multipath-hostonly/module-setup.sh
deleted file mode 100755 (executable)
index 8883903..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-
-# called by dracut
-check() {
-    return 255
-}
-
-# called by dracut
-depends() {
-    echo multipath
-    return 0
-}
-
-# called by dracut
-install() {
-    local _f _allow
-
-    is_mpath() {
-        local _dev=$1
-        [ -e /sys/dev/block/$_dev/dm/uuid ] || return 1
-        [[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ mpath- ]] && return 0
-        return 1
-    }
-
-    majmin_to_mpath_dev() {
-        local _dev
-        for i in /dev/mapper/*; do
-            [[ $i == /dev/mapper/control ]] && continue
-            _dev=$(get_maj_min $i)
-            if [ "$_dev" = "$1" ]; then
-                echo $i
-                return
-            fi
-        done
-    }
-
-    add_hostonly_mpath_conf() {
-        is_mpath $1 && {
-            local _dev
-
-            _dev=$(majmin_to_mpath_dev $1)
-            [ -z "$_dev" ] && return
-            strstr "$_allow" "$_dev" && return
-            _allow="$_allow --allow $_dev"
-        }
-    }
-
-    [[ $hostonly ]] && {
-        for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
-        [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
-    }
-}
-
index 446dceb012510ca945919285346ba2c4629d4cb3..f825c00cd6c9e8ec8a5c1f636b67a7308f82ad46 100755 (executable)
@@ -7,6 +7,18 @@ is_mpath() {
     return 1
 }
 
+majmin_to_mpath_dev() {
+    local _dev
+    for i in /dev/mapper/*; do
+        [[ $i == /dev/mapper/control ]] && continue
+        _dev=$(get_maj_min $i)
+        if [ "$_dev" = "$1" ]; then
+            echo $i
+            return
+        fi
+    done
+}
+
 # called by dracut
 check() {
     local _rootdev
@@ -55,6 +67,17 @@ installkernel() {
 install() {
     local _f _allow
 
+    add_hostonly_mpath_conf() {
+        is_mpath $1 && {
+            local _dev
+
+            _dev=$(majmin_to_mpath_dev $1)
+            [ -z "$_dev" ] && return
+            strstr "$_allow" "$_dev" && return
+            _allow="$_allow --allow $_dev"
+        }
+    }
+
     inst_multiple -o  \
         dmsetup \
         kpartx \
@@ -69,6 +92,11 @@ install() {
         /etc/multipath/* \
         /etc/multipath/conf.d/*
 
+    [[ $hostonly ]] && [[ $hostonly_mode = "strict" ]] && {
+        for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
+        [ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
+    }
+
     inst $(command -v partx) /sbin/partx
 
     inst_libdir_file "libmultipath*" "multipath/*"