Blame 0016-dracut-functions.sh-check_block_and_slaves-skip-LVM-.patch

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