Author: glen
Date: Wed Oct 24 19:26:16 2007
New Revision: 8853

Modified:
   geninitrd/trunk/geninitrd
Log:
- cvs detect multipath

Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd   (original)
+++ geninitrd/trunk/geninitrd   Wed Oct 24 19:26:16 2007
@@ -61,6 +61,8 @@
 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 @@
        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 @@
                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 @@
                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 @@
                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 @@
                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 @@
        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 @@
                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 @@
        initrd_gen_dmraid
 fi
 
-if [ "$USE_MULTIPATH" ]; then
+if [ "$use_multipath" ]; then
        initrd_gen_multipath
 fi
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to