dracut/0016-dracut-functions.sh-check_block_and_slaves-skip-LVM-.patch
Harald Hoyer 9323733aa3 dracut-034-18.git20131018
- Fixed LVM with thin provisioning
Resolves: rhbz#1013767
- fixed swap detection in host only mode
2013-10-18 15:02:35 +02:00

51 lines
2.0 KiB
Diff

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