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