[Dmraid-debian-commits] [SCM] Maintenance of the dmraid package branch, master, updated. debian/1.0.0.rc15-1.exp6-4-g072319d

Luke Yelavich luke.yelavich at canonical.com
Fri Feb 13 01:12:21 UTC 2009


The following commit has been merged in the master branch:
commit fdef4bb528b4e46f882f94943434d92c58ffa319
Author: Luke Yelavich <luke.yelavich at canonical.com>
Date:   Fri Feb 13 11:51:15 2009 +1100

    debian/dmraid-activate: Refactor code to allow for special casing of raid groups and subsets
    
    Some software raid metadata allows for groups of RAID sets, like Intel
    Software RAID, which allows up to 2 RAID sets per group. These sets
    cannot be activated in one go with the group name, and we don't want it to,
    since such a setup in theory allows each set to use a secondary/etc disk.
    This code change will bring up each subset if it has all members of the set
    present, or if the user specifically wants the array brought up in degraded
    mode.

diff --git a/debian/changelog b/debian/changelog
index cca7425..df7a3b6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,10 @@ dmraid (1.0.0.rc15-1~exp7) UNRELEASED; urgency=low
 
   * debian/initramfs/dmraid.initramfs-hook/dmraid: create udev rules dir
     before copying each udev rule
+  * debian/dmraid-activate: Refactor code to allow for special casing of
+    raid groups and subsets
 
- -- Luke Yelavich <themuso at ubuntu.com>  Fri, 13 Feb 2009 11:43:25 +1100
+ -- Luke Yelavich <themuso at ubuntu.com>  Fri, 13 Feb 2009 11:46:38 +1100
 
 dmraid (1.0.0.rc15-1~exp6) experimental; urgency=low
 
diff --git a/debian/dmraid-activate b/debian/dmraid-activate
index 670cb9d..558b599 100644
--- a/debian/dmraid-activate
+++ b/debian/dmraid-activate
@@ -19,6 +19,78 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
+# Arguments: $1 = Name of array you want activated.
+activate_array ()
+{
+	Raid_Setinfo=$(dmraid -i -si "$1")
+	if [ -z "$Raid_Setinfo" ]; then
+		log_error "Cannot retrieve RAID set information for $1"
+		return 1
+	fi
+
+	Raid_Type=$(dmraid -i -si -ct "$1")
+	Raid_Nodevs=$(dmraid -i -si -cd "$1")
+
+	case "$Raid_Type" in
+		stripe)
+			if [ "$Raid_Nodevs" -lt 2 ]; then
+				if [ -n "$Degraded" ]; then
+					log_error "Cannot bring up a RAID0 array in degraded mode, not all devices present."
+				fi
+				return 2
+			fi
+			;;
+		mirror)
+			if [ "$Raid_Nodevs" -lt 2 ]; then
+				if [ -z "$Degraded" ]; then
+					log_error "Raid set $Raid_Name is degraded. Not activating"
+					return 2
+				else
+					log_warning "Activating $Raid_Name in degraded mode"
+					Return_Val=3
+				fi
+			fi
+			;;
+		raid5_*)
+			modprobe -q dm_raid45
+			if [ "$Raid_Nodevs" -lt 3 ]; then
+				if [ -z "$Degraded" ]; then
+					log_error "Raid set $Raid_Name is degraded. Not activating"
+					return 2
+				else
+					log_warning "Activating $Raid_Name in degraded mode"
+					Return_Val=3
+				fi
+			fi
+			;;
+	esac
+
+	# At this point we have the required number of devs, or the user wants the
+	# array brought up in degraded mode, except in the case of striped arrays.
+	dmraid -i -ay "$1"
+	return $Return_Val
+}
+
+log_warning()
+{
+	if type logger > /dev/null ; then
+		logger -t dmraid-activate "WARNING: $1"
+	else
+		echo "dmraid-activate: WARNING: $1"
+	fi
+}
+
+log_error()
+{
+	if type logger > /dev/null ; then
+		logger -t dmraid-activate "ERROR: $1"
+	else
+		echo "dmraid-activate: ERROR: $1"
+	fi
+}
+
+modprobe -q dm_mod
+
 if [ -z "$1" ] || [ "$1" = "--degraded" ] && [ "$#" -lt 2 ]; then
 	echo "Node name not specified." >&2
 	exit 1
@@ -37,45 +109,23 @@ if [ -z "$Raid_Name" ]; then
 	exit 0
 fi
 
-Raid_Setinfo=$(dmraid -i -si $Raid_Name)
-if [ -z "$Raid_Setinfo" ]; then
-	exit 0
-fi
-
-Raid_Type=$(dmraid -i -si -ct $Raid_Name)
-Raid_Nodevs=$(dmraid -i -si -cd $Raid_Name)
+# We need a special case for isw arrays, since it is possible to have several
+# subsets of a RAID group, of varying RAID types.
+case "$Raid_Name" in
+	isw_*)
+		Isw_Group_Name=$(echo "$Raid_Name" | cut -f 1-2 -d _)
+		Isw_Subsets=$(dmraid -i -n "/dev/$Node_Name" | grep volume | sed 's/.*volume: " *\(.*\)"$/\1/')
 
-case "$Raid_Type" in
-	stripe)
-		if [ "$Raid_Nodevs" -lt 2 ]; then
-			if [ -n "$Degraded" ]; then
-				echo "Cannot bring up a RAID0 array in degraded mode."
-			fi
-			exit 1
-		fi
-		;;
-	mirror)
-		if [ "$Raid_Nodevs" -lt 2 ] && [ -z "$Degraded" ]; then
-			exit 1
-		fi
+		for isw_subset in $Isw_Subsets
+		do
+			activate_array "${Isw_Group_Name}_${isw_subset}"
+		done
+		break
 		;;
-	raid5_*)
-		if [ "$Raid_Nodevs" -lt 3 ] && [ -z "$Degraded" ]; then
-			exit 1
-		fi
+	*)
+		activate_array "$Raid_Name"
+		break
 		;;
 esac
 
-# At this point we have the required number of devs, or the user wants the
-# array brought up in degraded mode, except in the case of striped arrays.
-if ! grep -q "dm_mod" /proc/modules ; then
-	modprobe dm_mod
-	modprobe -q dm_raid45
-fi
-
-dmraid -i -ay $Raid_Name
-
-#FIXME (LP #310928)
-if echo "$Raid_Name" | grep -q "isw_" ; then
-	dmraid -i -ay -f isw
-fi
+exit $Return_Val

-- 
Maintenance of the dmraid package



More information about the Dmraid-debian-commits mailing list