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