[readonly/geninitrd: 457/1068] - cvs detect multipath

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


commit 9baf4f3f66c07ba07515402ca0ccd05b47a5aa10
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Wed Oct 24 17:26:16 2007 +0000

    - cvs detect multipath
    
    svn-id: @8853

 geninitrd | 46 +++++++++++++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 17 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 8926a88..8b1cf43 100755
--- a/geninitrd
+++ b/geninitrd
@@ -61,6 +61,8 @@ tmpfs_dev=no
 proc_partitions=no
 # dmraid component devices of rootfs is on dmraid
 dmraid_devices=''
+# if we should init dm-multipath at boot
+use_multipath=no
 
 if [ -f /etc/udev/udev.conf -a -x /sbin/initrd-udevd ]; then
 	USE_UDEV="yes"
@@ -275,7 +277,6 @@ inst() {
 	if [ "$#" -lt "2" ];then
 		die 'Usage: inst <file> $MNTIMAGE<destination>'
 	fi
-	debug "$1${3:+ ...} -> $MNTIMAGE$2"
 	cp -HR "$1" "$MNTIMAGE$2"
 }
 
@@ -284,7 +285,6 @@ inst_d() {
 		die 'Usage: inst_d $MNTIMAGE<destination> $MNTIMAGE<destination>'
 	fi
 	for dir in "$@"; do
-		debug "mkdir $MNTIMAGE$dir"
 		install -d "$MNTIMAGE$dir"
 	done
 }
@@ -524,6 +524,7 @@ find_modules_for_device() {
 		devpath=$(dm_longname "$devpath")
 		;;
 	esac
+	debug "find_modules_for_device($devpath)"
 
 	if is_yes "`echo "$devpath" | awk '/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:|\/dev\/nfs)/ { print "yes"; }'`"; then
 		if [ ! -x /usr/bin/pcidev -a -z "$NFS_ETH_MODULES" ] ; then
@@ -536,16 +537,37 @@ find_modules_for_device() {
 		findmodule "-ipv4"
 		findmodule "nfs"
 		usenfs="yes"
-		echo "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel" >&2
-		echo "or you will have problems like init(xx) being child process of swapper(1)." >&2
+		echo >&2 "Remember to use \`root=/dev/ram0 init=/linuxrc' when starting kernel"
+		echo >&2 "or you will have problems like init(xx) being child process of swapper(1)."
 		return
 	fi
 
-	if is_yes "`echo "$devpath" | awk '/^\/dev\/md/ { print "yes"; }'`"; then
+	if [[ "$devpath" == /dev/md/* ]]; then
 		find_modules_softraid "$devpath"
 		return
 	fi
 
+	if [[ "$devpath" == /dev/mapper/* ]] && is_yes "$USE_MULTIPATH"; then
+		# remove partition info
+		local disk=${devpath%p[0-9]*}
+		local info=$(dmsetup table $disk)
+		debug "dmsetup table: $info"
+
+		if [[ "$info" == *multipath* ]]; then
+			use_multipath=yes
+			findmodule "dm-mod"
+			findmodule "dm-multipath"
+
+			[[ "$info" == *round-robin* ]] && findmodule "dm-round-robin"
+			[[ "$info" == *emc* ]] && findmodule "dm-emc"
+			return
+			# TODO
+			# fallback to multipath containers
+		fi
+
+		# fallback
+	fi
+
 	if is_yes "$(echo "$devpath" | awk '/^\/dev\/(sd|scsi)/ { print "yes"; }')" ; then
 		find_modules_scsi
 		return
@@ -556,10 +578,6 @@ find_modules_for_device() {
 		return
 	fi
 
-	if [[ "$devpath" == /dev/mapper/* ]] && is_yes "$USE_MULTIPATH"; then
-		:
-	fi
-
 	if is_yes "$(echo "$devpath" | awk '/^\/dev\/mapper\/(sil|hpt37x|hpt45x|isw|lsi|nvidia|pdc|sil|via|dos)_/ { print "yes"; }')"; then
 		# dmraid nodes taken from: `dmraid -l` output
 		if [ ! -x /usr/sbin/dmraid ]; then
@@ -1062,12 +1080,6 @@ if is_yes "$FB_SPLASH"; then
 	findmodule "-evdev"
 fi
 
-if is_yes "$USE_MULTIPATH"; then
-	findmodule "dm-multipath"
-	findmodule "dm-round-robin"
-	findmodule "dm-emc"
-fi
-
 if [ -n "$ifneeded" -a -z "$MODULES" ]; then
 	debug "No modules are needed -- not building initrd image."
 	exit 0
@@ -1467,7 +1479,7 @@ initrd_gen_lvm() {
 		if is_yes "$raidfound"; then
 			echo "	md_component_detection = 1" >> "$MNTIMAGE/etc/lvm.conf"
 		fi
-		if [ "$dmraid_devices" ] || is_yes "$USE_MULTIPATH"; then
+		if [ "$dmraid_devices" ] || is_yes "$use_multipath"; then
 			echo '	types = [ "device-mapper", 254 ]' >> "$MNTIMAGE/etc/lvm.conf"
 		fi
 		if [ "$dmraid_devices" ]; then
@@ -1548,7 +1560,7 @@ if [ "$dmraid_devices" ]; then
 	initrd_gen_dmraid
 fi
 
-if [ "$USE_MULTIPATH" ]; then
+if [ "$use_multipath" ]; then
 	initrd_gen_multipath
 fi
 
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list