[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#468832: multipath support



Hi Frans,
On Mon, Mar 03, 2008 at 10:16:17PM +0100, Frans Pop wrote:
> In general I'm not sure that this approach is correct. In the case of SATA
> RAID, the BIOS actually knows what the RAID devices are and the RAID device
> _is_ what you select in the BIOS as the "disk" to be booted from.
In the multipath case you basically do the same and the select the WWID
in the FC adapter to boot from - I've updated the template accordingly.

> Also, I suspect that multipath is not i386/amd64-specific, and is probably
> quite interesting for other (mini system) arches. It would be good to contact
> porters about supporting multipath setups in their boot loaders
No it isn't. We certainly want to have this at least on powerpc as well.
Things will become much wore interesting once we have iSCSI support in
d-i, then everybody can use this at home.

> > The current code has:
> > - if ... [ $frgrubroot -gt 0 ] && [ -e $ROOT$frdev$frbootpart ]; then
> > which I changed to
> > + if ... [ $frgrubroot -ge 0 ] && [ -e $ROOT$frdev$frbootpart ]; then
> > since grub starts counting from zero. I wonder why sataraid can only
> > have partition numbers > 0?
> 
> I think you are correct. They are basically just sanity checks.
> I have committed this fix to SVN. As it is a bugfix, it should not be mixed
> in with your other changes.
Thanks.

> Some comments on the patch.
> 
> + GRUB is always installed to the master boot record (MBR) of the multipath
> + device. It is also assumed that that this device is listed as the first hard
> + device in the boot order defined in the system's BIOS setup.
> 
> "first hard _device_" is a meaningless term IMO.
Yes, this should be device only. Fixed.

> + An error occurred while setting up GRUB for the multipathed device.
> 
> I have seen you use "multipathed" before and every time my reaction was
> "ugh, ugly". Why not just use "multipath" instead? IMO the meaning remains
> identical.
Indeed, let's just use multipath.

> Spaces before tabs in indentation.
> (There were quite a few of those already in SVN, which I have cleaned up;
> you may have to update your patch for that.)
I cleaned that up - most of was came in due copy paste from other places
in the file. Thanks again for the comments, a new version is attached.
 -- Guido
>From ee695c71e1e71c697087cf32aeec99bdcd016f92 Mon Sep 17 00:00:00 2001
From: Guido Guenther <agx@sigxcpu.org>
Date: Fri, 7 Mar 2008 21:07:28 +0100
Subject: [PATCH] add multipath support modeled after dmraid

---
 debian/grub-installer.templates |   21 ++++++++++++++++
 debian/isinstallable            |   13 +++++++++-
 grub-installer                  |   50 +++++++++++++++++++++++++++++---------
 3 files changed, 71 insertions(+), 13 deletions(-)
 mode change 100755 => 100644 grub-installer

diff --git a/debian/grub-installer.templates b/debian/grub-installer.templates
index 183d9cd..d6e26bb 100644
--- a/debian/grub-installer.templates
+++ b/debian/grub-installer.templates
@@ -47,6 +47,27 @@ _Description: Unable to configure GRUB
  .
  The GRUB installation has been aborted.
 
+Template: grub-installer/multipath
+Type: boolean
+Default: true
+# :sl3:
+_Description: Install the GRUB boot loader to the multipath device?
+ Installation of GRUB on multipath is experimental.
+ .
+ GRUB is always installed to the master boot record (MBR) of the multipath
+ device. It is also assumed that the WWID of this device is selected as boot
+ device in the system's FibreChannel adapter BIOS.
+ .
+ The GRUB root device is: ${GRUBROOT}.
+
+Template: grub-installer/multipath-error
+Type: error
+# :sl2:
+_Description: Unable to configure GRUB
+ An error occurred while setting up GRUB for the multipath device.
+ .
+ The GRUB installation has been aborted.
+
 Template: grub-installer/install_to_xfs
 Type: boolean
 Default: false
diff --git a/debian/isinstallable b/debian/isinstallable
index 73ddfcf..6e2eb41 100755
--- a/debian/isinstallable
+++ b/debian/isinstallable
@@ -24,6 +24,17 @@ is_sataraid () {
 	return 1
 }
 
+is_multipath () {
+	if type multipath >/dev/null 2>&1; then
+		for frdisk in $(multipath -l 2>/dev/null | grep '^mpath[0-9]\+ ' | cut -d ' ' -f 1); do
+			if echo "$1" | grep -q "^/dev/mapper/${frdisk}-part[0-9]\+"; then
+				return 0
+			fi
+		done
+	fi
+	return 1
+}
+
 ARCH="$(archdetect)"
 
 case $ARCH in
@@ -53,7 +64,7 @@ fi
 # Check for the control file to work around lvdisplay refusal to work with
 # certian lvm device names.
 if lvdisplay "$bootfs" | grep -q 'LV Name' 2>/dev/null || [ -e "$(dirname $bootfs)/control" ]; then
-	if ! is_sataraid $bootfs; then
+	if ! is_sataraid $bootfs && ! is_multipath $bootfs; then
 		log "/boot is a lvm volume ($bootfs), cannot install grub"
 		exit 1
 	fi
diff --git a/grub-installer b/grub-installer
old mode 100755
new mode 100644
index 2bf8020..5f86517
--- a/grub-installer
+++ b/grub-installer
@@ -99,12 +99,14 @@ convert () {
 		tmp_disk=$(echo "$1" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
 				  -e 's%\(fd[0-9]*\)$%\1%' \
 				  -e 's%/part[0-9]*$%/disc%' \
-				  -e 's%\(c[0-7]d[0-9]*\).*$%\1%')
+				  -e 's%\(c[0-7]d[0-9]*\).*$%\1%' \
+				  -e 's%\(/mapper/mpath[0-9]\+\)-part[0-9]\+$%\1%')
 		tmp_part=$(echo "$1" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
 				  -e 's%.*/fd[0-9]*$%%' \
 				  -e 's%.*/floppy/[0-9]*$%%' \
 				  -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
-				  -e 's%.*c[0-7]d[0-9]*p*%%')
+				  -e 's%.*c[0-7]d[0-9]*p*%%' \
+				  -e 's%.*/mapper/mpath[0-9]\+-part\([0-9]\+\)%\1%')
 		;;
 	    gnu*)
 		tmp_disk=$(echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%')
@@ -276,9 +278,29 @@ if type dmraid >/dev/null 2>&1; then
 			frdev=/dev/mapper/$frdisk
 			frbootpart=${disc_offered#$frdev}
 			frgrubroot=$(($frbootpart - 1))
+			frtype=sataraid
 			break
 		fi
 	done
+# Check if the boot file system is on multipath
+elif type multipath >/dev/null 2>&1; then
+	for frdisk in $(multipath -l 2>/dev/null | \
+			grep '^mpath[0-9]\+ ' | cut -d ' ' -f 1); do
+		if echo "$disc_offered" | 	   \
+			grep -q "^/dev/mapper/${frdisk}-part[0-9]\+"; then
+			frdev=/dev/mapper/$frdisk
+			frbootpart=${disc_offered#$frdev}
+			frgrubroot=$((${frbootpart#-part} - 1))
+			frtype=multipath
+			break
+		fi
+	done
+	if [ "$frdisk" ]; then
+		# Create the device nodes for grub:
+		apt-install dmsetup
+		$chroot $ROOT mount /proc
+		$chroot $ROOT dmsetup mknodes
+	fi
 fi
 
 info "Identified partition label for $bootfs: $bootfslabel"
@@ -380,6 +402,10 @@ if ! apt-install $grub_package ; then
 	exit 1
 fi
 
+if [ "$frtype" = multipath ]; then
+	$chroot $ROOT umount /proc
+fi
+
 db_progress STEP 1
 db_progress INFO grub-installer/progress/step_os-probe
 os-prober > /tmp/os-probed || true
@@ -450,10 +476,10 @@ fi
 if [ "$frdev" ]; then
 	if [ -e $ROOT$frdev ] && [ -e $ROOT$frdev$frbootpart ] && \
 	   [ $frgrubroot -ge 0 ]; then
-		db_subst grub-installer/sataraid GRUBROOT $ROOT$frdev$frbootpart
-		q=grub-installer/sataraid
+		db_subst grub-installer/$frtype GRUBROOT $ROOT$frdev$frbootpart
+		q=grub-installer/$frtype
 	else
-		db_input critical grub-installer/sataraid-error
+		db_input critical grub-installer/${frtype}-error
 		db_go || true
 		exit 1
 	fi
@@ -475,8 +501,8 @@ while : ; do
 			bootdev="(hd0)"
 			break
 		else
-			# Exit to menu if /boot is on SATA RAID; we don't
-			# support device selection in that case
+			# Exit to menu if /boot is on SATA RAID/multipath; we
+			# don't support device selection in that case
 			if [ "$frdev" ]; then
 				db_progress STOP
 				exit 10
@@ -554,8 +580,8 @@ if [ -z "$frdisk" ]; then
 
 else
 
-	# Semi-manual grub setup for Serial ATA RAID
-	info "Boot partition is on a Serial ATA RAID disk"
+	# Semi-manual grub setup for Serial ATA RAID/multipath
+	info "Boot partition is on a Serial ATA RAID disk or multipath device"
 	info "Installing GRUB to $frdev; grub root is $disc_offered"
 	case $(archdetect) in
 	    i386/*)
@@ -563,7 +589,7 @@ else
 	    amd64/*)
 		stagedir=x86_64-pc ;;
 	    *)
-		error "Unsupported architecture for SATA RAID installation"
+		error "Unsupported architecture for SATA RAID/multipath installation"
 		exit 1
 		;;
 	esac
@@ -576,7 +602,7 @@ else
 
 	# TODO: Check for errors during this process!
 	TERM=linux $chroot $ROOT \
-        grub --device-map=/dev/null >/var/log/grub-dmraid.log 2>&1 </dev/null <<EOF
+        grub --device-map=/dev/null >/var/log/grub-${frtype}.log 2>&1 </dev/null <<EOF
 device (hd0,$frgrubroot) $disc_offered
 device (hd0) $frdev
 root (hd0,$frgrubroot)
@@ -593,7 +619,7 @@ db_progress INFO grub-installer/progress/step_config_loader
 rm -f $ROOT/boot/grub/$menu_file
 update_grub
 
-# For SATA RAID we may need to update the grub root
+# For SATA RAID/multipath we may need to update the grub root
 # TODO: This should really be supported in update-grub
 if [ "$frdev" ] && [ $frgrubroot -gt 0 ]; then
 	sed -i "/^root/s/(hd0,0)/(hd0,$frgrubroot)/
-- 
1.5.4.3


Reply to: