[readonly/geninitrd: 458/1068] - detect physical devices for dm-multipath

draenog draenog at pld-linux.org
Sat Nov 2 19:50:52 CET 2013


commit aabf157cbf2b2b0f6726472f529c0aa1ddc1a6fe
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Wed Oct 24 17:58:10 2007 +0000

    - detect physical devices for dm-multipath
    
    svn-id: @8854

 geninitrd | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 8b1cf43..1052376 100755
--- a/geninitrd
+++ b/geninitrd
@@ -548,21 +548,31 @@ find_modules_for_device() {
 	fi
 
 	if [[ "$devpath" == /dev/mapper/* ]] && is_yes "$USE_MULTIPATH"; then
-		# remove partition info
+		# remove partition
 		local disk=${devpath%p[0-9]*}
-		local info=$(dmsetup table $disk)
-		debug "dmsetup table: $info"
+		local id=${disk#/dev/mapper/}
 
-		if [[ "$info" == *multipath* ]]; then
+		local info=$(multipath -l $id)
+		if [ "$info" ]; then
+			debug "have multipath"
 			use_multipath=yes
-			findmodule "dm-mod"
-			findmodule "dm-multipath"
+			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
 
-			[[ "$info" == *round-robin* ]] && findmodule "dm-round-robin"
-			[[ "$info" == *emc* ]] && findmodule "dm-emc"
+			local target targets=$(echo "$info" | awk '/prio=/{print $2}' | sort -u)
+			for target in $targets; do
+				findmodule "dm-$target"
+			done
+
+			findmodule "dm-mod"
 			return
-			# TODO
-			# fallback to multipath containers
 		fi
 
 		# fallback
@@ -1267,10 +1277,10 @@ initrd_gen_multipath() {
 	fi
 	inst_d $lib
 	inst /lib64/ld-linux-x86-64.so.2 $lib
-	for a in $(ldd /sbin/kpartx /sbin/multipath | awk '{print $3}'); do
+	for a in $(ldd /sbin/kpartx /sbin/multipath | grep -v linux-gate.so | sort -u | awk '{print $3}'); do
 	   	inst $a $lib
 	done
-	for a in $(ldd $MNTIMAGE$lib/lib* | awk '{print $3}'); do
+	for a in $(ldd $MNTIMAGE$lib/lib* | grep -v linux-gate.so | sort -u | awk '{print $3}'); do
 	   	inst $a $lib
 	done
 
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list