Blame SOURCES/0027-dracut-functions.sh-check_block_and_slaves-skip-LVM-.patch

712866
From 8e3620568cd4e2c7e8db52fcf3f6e25cc4608aaf Mon Sep 17 00:00:00 2001
712866
From: Marian Csontos <mcsontos@redhat.com>
712866
Date: Fri, 18 Oct 2013 14:40:40 +0200
712866
Subject: [PATCH] dracut-functions.sh:check_block_and_slaves*() skip LVM
712866
 internal devs
712866
712866
Not every device in /dev/mapper should be examined.
712866
If it is an LVM device, touch only devices which have /dev/VG/LV symlink.
712866
---
712866
 dracut-functions.sh | 16 ++++++++++++++--
712866
 1 file changed, 14 insertions(+), 2 deletions(-)
712866
712866
diff --git a/dracut-functions.sh b/dracut-functions.sh
5c6c2a
index 45e09118..2e6e8456 100755
712866
--- a/dracut-functions.sh
712866
+++ b/dracut-functions.sh
712866
@@ -579,7 +579,7 @@ host_fs_all()
712866
 check_block_and_slaves() {
712866
     local _x
712866
     [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
712866
-    "$1" $2 && return
712866
+    if ! lvm_internal_dev $2; then "$1" $2 && return; fi
712866
     check_vol_slaves "$@" && return 0
712866
     if [[ -f /sys/dev/block/$2/../dev ]]; then
712866
         check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0
712866
@@ -595,7 +595,7 @@ check_block_and_slaves() {
712866
 check_block_and_slaves_all() {
712866
     local _x _ret=1
712866
     [[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
712866
-    if "$1" $2; then
712866
+    if ! lvm_internal_dev $2 && "$1" $2; then
712866
         _ret=0
712866
     fi
712866
     check_vol_slaves "$@" && return 0
712866
@@ -1672,3 +1672,15 @@ get_ucode_file ()
712866
         printf "%02x-%02x-%02x" ${family} ${model} ${stepping}
712866
     fi
712866
 }
712866
+
712866
+# Not every device in /dev/mapper should be examined.
712866
+# If it is an LVM device, touch only devices which have /dev/VG/LV symlink.
712866
+lvm_internal_dev() {
712866
+    local dev_dm_dir=/sys/dev/block/$1/dm
712866
+    [[ ! -f $dev_dm_dir/uuid || $(<$dev_dm_dir/uuid) != LVM-* ]] && return 1 # Not an LVM device
712866
+    local DM_VG_NAME DM_LV_NAME DM_LV_LAYER
712866
+    eval $(dmsetup splitname --nameprefixes --noheadings --rows "$(<$dev_dm_dir/name)" 2>/dev/null)
712866
+    [[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 0 # Better skip this!
712866
+    [[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]]
712866
+}
712866
+