[readonly/geninitrd: 461/1068] - moved dm-multipath handling to function

draenog draenog at pld-linux.org
Sat Nov 2 19:51:08 CET 2013


commit 07137fe30cd79e97c35a5f47e2dd420e7b83cb11
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Wed Oct 24 18:20:06 2007 +0000

    - moved dm-multipath handling to function
    
    svn-id: @8857

 geninitrd | 63 ++++++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 38 insertions(+), 25 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 0fbf79b..390e1f2 100755
--- a/geninitrd
+++ b/geninitrd
@@ -517,6 +517,42 @@ _check_lvm() {
 	return $rc
 }
 
+# find dm-multipath modules for $devpath
+# returns false if $devpath is not dm-multipath
+find_modules_multipath() {
+	local devpath="$1"
+
+	# remove partition, if any
+	local disk=${devpath%p[0-9]*}
+	# need only dm name
+	local id=${disk#/dev/mapper/}
+
+	local info=$(multipath -l $id)
+	if [ -z "$info" ]; then
+		return 1
+	fi
+
+	debug "have multipath"
+	have_multipath=yes
+	local dev phydevs=$(echo "$info" | awk '$2 ~ /^[0-9]+:[0-9]+:[0-9]+:[0-9]+$/{printf("/dev/%s\n", $3)}')
+	for dev in $phydevs; do
+		find_modules_for_device $dev
+	done
+
+	local hw hwhandlers=$(echo "$info" | awk '/hwhandler=1/{sub(/.*hwhandler=1 /, ""); sub(/\]$/, ""); print}')
+	for hw in $hwhandlers; do
+		findmodule "dm-$hw"
+	done
+
+	local target targets=$(echo "$info" | awk '/prio=/{print $2}' | sort -u)
+	for target in $targets; do
+		findmodule "dm-$target"
+	done
+
+	findmodule "dm-mod"
+	return 0
+}
+
 # find modules for $devpath
 find_modules_for_device() {
 	local devpath="$1"
@@ -536,6 +572,7 @@ find_modules_for_device() {
 		if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ] ; then
 			die "root on NFS but /usr/bin/pcidev not found. Please install correct pci-database package and rerun $PROGRAM."
 		fi
+		local m
 		[ -z "$NFS_ETH_MODULES" ] && NFS_ETH_MODULES=$(/usr/bin/pcidev /m net | xargs)
 		for m in $NFS_ETH_MODULES; do
 			findmodule "$m"
@@ -554,33 +591,9 @@ find_modules_for_device() {
 	fi
 
 	if [[ "$devpath" == /dev/mapper/* ]] && is_yes "$USE_MULTIPATH"; then
-		# remove partition
-		local disk=${devpath%p[0-9]*}
-		local id=${disk#/dev/mapper/}
-
-		local info=$(multipath -l $id)
-		if [ "$info" ]; then
-			debug "have multipath"
-			have_multipath=yes
-			local dev phydevs=$(echo "$info" | awk '$2 ~ /^[0-9]+:[0-9]+:[0-9]+:[0-9]+$/{printf("/dev/%s\n", $3)}')
-			for dev in $phydevs; do
-				find_modules_for_device $dev
-			done
-
-			local hw hwhandlers=$(echo "$info" | awk '/hwhandler=1/{sub(/.*hwhandler=1 /, ""); sub(/\]$/, ""); print}')
-			for hw in $hwhandlers; do
-				findmodule "dm-$hw"
-			done
-
-			local target targets=$(echo "$info" | awk '/prio=/{print $2}' | sort -u)
-			for target in $targets; do
-				findmodule "dm-$target"
-			done
-
-			findmodule "dm-mod"
+		if find_modules_multipath "$devpath"; then
 			return
 		fi
-
 		# fallback
 	fi
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list