Blame SOURCES/0451-dracut-functions.sh-catch-all-lvm-slaves.patch

a0a3b4
From 7a7b8c174023886b015bd484372839aecf63f324 Mon Sep 17 00:00:00 2001
a0a3b4
From: Harald Hoyer <harald@redhat.com>
a0a3b4
Date: Tue, 9 Aug 2016 15:26:04 +0200
a0a3b4
Subject: [PATCH] dracut-functions.sh: catch all lvm slaves
a0a3b4
a0a3b4
add check_vol_slaves_all to be used in check_block_and_slaves_all
a0a3b4
a0a3b4
otherwise only the first lvm VG member would be processed
a0a3b4
---
a0a3b4
 dracut-functions.sh | 25 ++++++++++++++++++++++++-
a0a3b4
 1 file changed, 24 insertions(+), 1 deletion(-)
a0a3b4
a0a3b4
diff --git a/dracut-functions.sh b/dracut-functions.sh
1755ca
index 4a9729c7..61726e44 100755
a0a3b4
--- a/dracut-functions.sh
a0a3b4
+++ b/dracut-functions.sh
a0a3b4
@@ -632,7 +632,7 @@ check_block_and_slaves_all() {
a0a3b4
     if ! lvm_internal_dev $2 && "$1" $2; then
a0a3b4
         _ret=0
a0a3b4
     fi
a0a3b4
-    check_vol_slaves "$@" && return 0
a0a3b4
+    check_vol_slaves_all "$@" && return 0
a0a3b4
     if [[ -f /sys/dev/block/$2/../dev ]]; then
a0a3b4
         check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
a0a3b4
     fi
a0a3b4
@@ -703,6 +703,29 @@ check_vol_slaves() {
a0a3b4
     return 1
a0a3b4
 }
a0a3b4
 
a0a3b4
+check_vol_slaves_all() {
a0a3b4
+    local _lv _vg _pv
a0a3b4
+    for i in /dev/mapper/*; do
a0a3b4
+        [[ $i == /dev/mapper/control ]] && continue
a0a3b4
+        _lv=$(get_maj_min $i)
a0a3b4
+        if [[ $_lv = $2 ]]; then
a0a3b4
+            _vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
a0a3b4
+            # strip space
a0a3b4
+            _vg="${_vg//[[:space:]]/}"
a0a3b4
+            if [[ $_vg ]]; then
a0a3b4
+                for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
a0a3b4
+                do
a0a3b4
+                    check_block_and_slaves_all $1 $(get_maj_min $_pv)
a0a3b4
+                done
a0a3b4
+                return 0
a0a3b4
+            fi
a0a3b4
+        fi
a0a3b4
+    done
a0a3b4
+    return 1
a0a3b4
+}
a0a3b4
+
a0a3b4
+
a0a3b4
+
a0a3b4
 # fs_get_option <filesystem options> <search for option>
a0a3b4
 # search for a specific option in a bunch of filesystem options
a0a3b4
 # and return the value