[PATCH] RAID10 and RAID6
Ryan Niebur
ryanryan52 at gmail.com
Thu Jul 17 21:15:37 UTC 2008
On Thu, Jul 17, 2008 at 10:45:04PM +0200, Frans Pop wrote:
> On Thursday 17 July 2008, Ryan Niebur wrote:
> > Here is a patch that adds support for RAID6 and RAID10 to the debian
> > installer.
>
> Thanks a lot.
>
> You seem to have moved two functions in that patch which have remained
> more or less the same. This makes review more difficult then it should
> be.
>
> Could you please submit a patch that contains only the actual functional
> changes? And if you think the move is needed, then do that in a separate
> patch first or after without any changes in the functions?
>
> From what I can tell reading around that noise the patch looks quite sane
> and contains a nice generalization of the create function. I think we
> should certainly consider this for Lenny. Main bottleneck will be the
> translation effort required.
>
> Thanks,
> FJP
Here is a new patch that doesn't move those functions, and makes changes to the debconf templates based on Martin's comments.
--
_________________________
Ryan Niebur
RyanRyan52 at gmail.com
-------------- next part --------------
Index: kernel/kernel-wedge/modules/md-modules
===================================================================
--- kernel/kernel-wedge/modules/md-modules (revision 54408)
+++ kernel/kernel-wedge/modules/md-modules (working copy)
@@ -8,6 +8,7 @@
raid1
raid5 ?
raid456 ?
+raid10
xor
dm-mirror ?
dm-snapshot ?
Index: mdcfg/debian/mdcfg-utils.templates
===================================================================
--- mdcfg/debian/mdcfg-utils.templates (revision 54408)
+++ mdcfg/debian/mdcfg-utils.templates (working copy)
@@ -47,7 +47,7 @@
Type: select
# :sl3:
# flag:translate:4
-__Choices: RAID0, RAID1, RAID5, Cancel
+__Choices: RAID0, RAID1, RAID5, RAID6, RAID10, Cancel
# :sl3:
_Description: Multidisk device type:
Please choose the type of the multidisk device to be created.
@@ -107,6 +107,80 @@
devices, the remaining partitions will be added to the array as "missing".
You will be able to add them later to the array.
+Template: mdcfg/raid6devcount
+Type: string
+# :sl3:
+_Description: Number of active devices for the RAID6 array:
+ The RAID6 array will consist of both active and spare partitions. The active
+ partitions are those used, while the spare devices will only be used if one or
+ more of the active devices fail. A minimum of four active devices is
+ required.
+ .
+ NOTE: this setting cannot be changed later.
+
+Template: mdcfg/raid6sparecount
+Type: string
+# :sl3:
+_Description: Number of spare devices for the RAID6 array:
+
+Template: mdcfg/raid6sparedevs
+Type: multiselect
+Choices: ${PARTITIONS}
+# :sl3:
+_Description: Spare devices for the RAID6 multidisk device:
+ You have chosen to create an RAID6 array with ${COUNT} spare devices.
+ .
+ Please choose which partitions will be used as spare devices.
+ You may choose up to ${COUNT} partitions. If you choose less than ${COUNT}
+ devices, the remaining partitions will be added to the array as "missing".
+ You will be able to add them later to the array.
+
+Template: mdcfg/raid10layout
+Type: string
+# :sl3:
+_Description: Layout of the RAID10 multidisk device:
+ The layout must be n, o, or f followed by a number.
+ .
+ The number is the number of copies of each chunk.
+ It has to be equal to or smaller than the number of active devices.
+ .
+ The letter is the arrangement of the copies.
+ n - near copies: Multiple copies of one data block are at similar offsets in different devices.
+ f - far copies: Multiple copies have very different offsets
+ o - offset copies: Rather than the chunks being duplicated within a stripe, whole stripes are duplicated but are rotated by one device so duplicate blocks are on different devices.
+ .
+ The default setting is n2.
+ .
+ NOTE: this setting cannot be changed later.
+
+Template: mdcfg/raid10devcount
+Type: string
+# :sl3:
+_Description: Number of active devices for the RAID10 array:
+ The RAID10 array will consist of both active and spare partitions. The active
+ partitions are those used, while the spare devices will only be used if one or
+ more of the active devices fail. A minimum of four (you can use two, though it
+ doesn't make much sense) active devices is required.
+ .
+ NOTE: this setting cannot be changed later.
+
+Template: mdcfg/raid10sparecount
+Type: string
+# :sl3:
+_Description: Number of spare devices for the RAID10 array:
+
+Template: mdcfg/raid10sparedevs
+Type: multiselect
+Choices: ${PARTITIONS}
+# :sl3:
+_Description: Spare devices for the RAID10 multidisk device:
+ You have chosen to create an RAID10 array with ${COUNT} spare devices.
+ .
+ Please choose which partitions will be used as spare devices.
+ You may choose up to ${COUNT} partitions. If you choose less than ${COUNT}
+ devices, the remaining partitions will be added to the array as "missing".
+ You will be able to add them later to the array.
+
Template: mdcfg/raid0devs
Type: multiselect
Choices: ${PARTITIONS}
@@ -135,6 +209,26 @@
Please choose which partitions are active devices.
You must select exactly ${COUNT} partitions.
+Template: mdcfg/raid6devs
+Type: multiselect
+Choices: ${PARTITIONS}
+# :sl3:
+_Description: Active devices for the RAID6 multidisk device:
+ You have chosen to create an RAID6 array with ${COUNT} active devices.
+ .
+ Please choose which partitions are active devices.
+ You must select exactly ${COUNT} partitions.
+
+Template: mdcfg/raid10devs
+Type: multiselect
+Choices: ${PARTITIONS}
+# :sl3:
+_Description: Active devices for the RAID10 multidisk device:
+ You have chosen to create an RAID10 array with ${COUNT} active devices.
+ .
+ Please choose which partitions are active devices.
+ You must select exactly ${COUNT} partitions.
+
Template: mdcfg/deletemenu
Type: select
# :sl3:
Index: mdcfg/mdcfg.sh
===================================================================
--- mdcfg/mdcfg.sh (revision 54408)
+++ mdcfg/mdcfg.sh (working copy)
@@ -102,14 +102,7 @@
return
fi
- case "$RAID_SEL" in
- RAID5)
- md_create_raid5 ;;
- RAID1)
- md_create_raid1 ;;
- RAID0)
- md_create_raid0 ;;
- esac
+ md_create_array "$RAID_SEL"
fi
}
@@ -199,215 +192,104 @@
-n $SELECTED $RAID_DEVICES
}
-md_create_raid1() {
+md_create_array(){
OK=0
- db_set mdcfg/raid1devcount 2
+ case "$1" in
+ RAID10)
+ MIN_SIZE=2 ;;
+ RAID6)
+ MIN_SIZE=4 ;;
+ RAID5)
+ MIN_SIZE=3 ;;
+ RAID1)
+ MIN_SIZE=2 ;;
+ RAID0)
+ md_create_raid0; return ;;
+ *)
+ return ;;
+ esac
- # Get the count of active devices
- while [ $OK -eq 0 ]; do
- db_input critical mdcfg/raid1devcount
- db_go
- if [ $? -eq 30 ]; then
- return
- fi
+ LEVEL=$(echo "$1" | sed s/RAID//)
- # Figure out, if the user entered a number
- db_get mdcfg/raid1devcount
- RET=$(echo $RET | sed -e "s/[[:space:]]//g")
- if [ "$RET" ]; then
- let "OK=${RET}>0 && ${RET}<99"
- fi
- done
-
- db_set mdcfg/raid1sparecount "0"
- OK=0
-
- # Same procedure as above, but get the number of spare partitions
- # this time.
- # TODO: Make a general function for this kind of stuff
- while [ $OK -eq 0 ]; do
- db_input critical mdcfg/raid1sparecount
- db_go
- if [ $? -eq 30 ]; then
- return
- fi
- db_get mdcfg/raid1sparecount
- RET=$(echo $RET | sed -e "s/[[:space:]]//g")
- if [ "$RET" ]; then
- let "OK=${RET}>=0 && ${RET}<99"
- fi
- done
-
- db_get mdcfg/raid1devcount
- DEV_COUNT="$RET"
- db_get mdcfg/raid1sparecount
- SPARE_COUNT="$RET"
- REQUIRED=$(($DEV_COUNT + $SPARE_COUNT))
-
- db_set mdcfg/raid1devs ""
- SELECTED=0
-
- # Loop until at least one device has been selected
- until [ $SELECTED -gt 0 ] && [ $SELECTED -le $DEV_COUNT ]; do
- db_subst mdcfg/raid1devs COUNT "$DEV_COUNT"
- db_subst mdcfg/raid1devs PARTITIONS "$PARTITIONS"
- db_input critical mdcfg/raid1devs
- db_go
- if [ $? -eq 30 ]; then
- return
- fi
-
- db_get mdcfg/raid1devs
- SELECTED=0
- for i in $RET; do
- DEVICE=$(echo $i | sed -e "s/,//")
- let SELECTED++
- done
- done
-
- # Add "missing" for as many devices as weren't selected
- MISSING_DEVICES=""
- while [ $SELECTED -lt $DEV_COUNT ]; do
- MISSING_DEVICES="$MISSING_DEVICES missing"
- let SELECTED++
- done
-
- # Remove partitions selected in raid1devs from the PARTITION list
- db_get mdcfg/raid1devs
-
- prune_partitions "$RET"
-
- db_set mdcfg/raid1sparedevs ""
- SELECTED=0
- if [ $SPARE_COUNT -gt 0 ]; then
- FIRST=1
- # Loop until the correct number of devices has been selected.
- # That means any number less than or equal to the spare count.
- while [ $SELECTED -gt $SPARE_COUNT ] || [ $FIRST -eq 1 ]; do
- FIRST=0
- db_subst mdcfg/raid1sparedevs COUNT "$SPARE_COUNT"
- db_subst mdcfg/raid1sparedevs PARTITIONS "$PARTITIONS"
- db_input critical mdcfg/raid1sparedevs
- db_go
- if [ $? -eq 30 ]; then
- return
- fi
-
- db_get mdcfg/raid1sparedevs
- SELECTED=0
- for i in $RET; do
- DEVICE=$(echo $i | sed -e "s/,//")
- let SELECTED++
- done
- done
+ DEFAULT="$MIN_SIZE"
+ if [ "$LEVEL" = "10" ]; then
+ DEFAULT=4
fi
- # The number of spares the user has selected
- NAMED_SPARES=$SELECTED
+ db_set mdcfg/raid${LEVEL}devcount "$DEFAULT"
- db_get mdcfg/raid1devs
- RAID_DEVICES=$(echo $RET | sed -e "s/,//g")
-
- db_get mdcfg/raid1sparedevs
- SPARE_DEVICES=$(echo $RET | sed -e "s/,//g")
-
- MISSING_SPARES=""
-
- COUNT=$NAMED_SPARES
- while [ $COUNT -lt $SPARE_COUNT ]; do
- MISSING_SPARES="$MISSING_SPARES missing"
- let COUNT++
- done
-
- # Find the next available md-number
- MD_NUM=$(grep ^md /proc/mdstat | \
- sed -e 's/^md\(.*\) : active .*/\1/' | sort | tail -n1)
- if [ -z "$MD_NUM" ]; then
- MD_NUM=0
- else
- let MD_NUM++
- fi
-
- logger -t mdcfg "Selected spare count: $NAMED_SPARES"
- logger -t mdcfg "Raid devices count: $DEV_COUNT"
- logger -t mdcfg "Spare devices count: $SPARE_COUNT"
- log-output -t mdcfg \
- mdadm --create /dev/md$MD_NUM --auto=yes --force -R -l raid1 \
- -n $DEV_COUNT -x $SPARE_COUNT $RAID_DEVICES $MISSING_DEVICES \
- $SPARE_DEVICES $MISSING_SPARES
-}
-
-md_create_raid5() {
- OK=0
-
- db_set mdcfg/raid5devcount "3"
-
# Get the count of active devices
while [ $OK -eq 0 ]; do
- db_input critical mdcfg/raid5devcount
+ db_input critical mdcfg/raid${LEVEL}devcount
db_go
if [ $? -eq 30 ]; then
return
fi
# Figure out, if the user entered a number
- db_get mdcfg/raid5devcount
+ db_get mdcfg/raid${LEVEL}devcount
RET=$(echo $RET | sed -e "s/[[:space:]]//g")
if [ "$RET" ]; then
let "OK=${RET}>0 && ${RET}<99"
fi
done
- db_set mdcfg/raid5sparecount "0"
+
+ db_set mdcfg/raid${LEVEL}sparecount "0"
OK=0
# Same procedure as above, but get the number of spare partitions
# this time.
# TODO: Make a general function for this kind of stuff
while [ $OK -eq 0 ]; do
- db_input critical mdcfg/raid5sparecount
+ db_input critical mdcfg/raid${LEVEL}sparecount
db_go
if [ $? -eq 30 ]; then
return
fi
- db_get mdcfg/raid5sparecount
+ db_get mdcfg/raid${LEVEL}sparecount
RET=$(echo $RET | sed -e "s/[[:space:]]//g")
if [ "$RET" ]; then
let "OK=${RET}>=0 && ${RET}<99"
fi
done
- db_get mdcfg/raid5devcount
+ db_get mdcfg/raid${LEVEL}devcount
DEV_COUNT="$RET"
- if [ $DEV_COUNT -lt 3 ]; then
- DEV_COUNT=3 # Minimum number for RAID5
+ if [ "$LEVEL" -ne "1" ]; then
+ if [ $DEV_COUNT -lt $MIN_SIZE ]; then
+ DEV_COUNT=$MIN_SIZE # Minimum number for the selected RAID level
+ fi
fi
- db_get mdcfg/raid5sparecount
+ db_get mdcfg/raid${LEVEL}sparecount
SPARE_COUNT="$RET"
REQUIRED=$(($DEV_COUNT + $SPARE_COUNT))
- if [ $REQUIRED -gt $NUM_PART ]; then
- db_subst mdcfg/notenoughparts NUM_PART "$NUM_PART"
- db_subst mdcfg/notenoughparts REQUIRED "$REQUIRED"
- db_input critical mdcfg/notenoughparts
- db_go mdcfg/notenoughparts
- return
+ if [ "$LEVEL" -ne "1" ]; then
+ if [ $REQUIRED -gt $NUM_PART ]; then
+ db_subst mdcfg/notenoughparts NUM_PART "$NUM_PART"
+ db_subst mdcfg/notenoughparts REQUIRED "$REQUIRED"
+ db_input critical mdcfg/notenoughparts
+ db_go mdcfg/notenoughparts
+ return
+ fi
fi
- db_set mdcfg/raid5devs ""
+ db_set mdcfg/raid${LEVEL}devs ""
SELECTED=0
- # Loop until the correct number of active devices has been selected
- while [ $SELECTED -ne $DEV_COUNT ]; do
- db_subst mdcfg/raid5devs COUNT "$DEV_COUNT"
- db_subst mdcfg/raid5devs PARTITIONS "$PARTITIONS"
- db_input critical mdcfg/raid5devs
+ # Loop until the correct number of active devices has been selected for RAID 5 and 10
+ # Loop until at least one device has been selected for RAID 1
+ until ([ "$LEVEL" -ne "1" ] && [ $SELECTED -eq $DEV_COUNT ]) || ([ "$LEVEL" -eq "1" ] && [ $SELECTED -gt 0 ] && [ $SELECTED -le $DEV_COUNT ]); do
+ db_subst mdcfg/raid${LEVEL}devs COUNT "$DEV_COUNT"
+ db_subst mdcfg/raid${LEVEL}devs PARTITIONS "$PARTITIONS"
+ db_input critical mdcfg/raid${LEVEL}devs
db_go
if [ $? -eq 30 ]; then
return
fi
- db_get mdcfg/raid5devs
+ db_get mdcfg/raid${LEVEL}devs
SELECTED=0
for i in $RET; do
DEVICE=$(echo $i | sed -e "s/,//")
@@ -415,12 +297,21 @@
done
done
- # Remove partitions selected in raid5devs from the PARTITION list
- db_get mdcfg/raid5devs
+ if [ "$LEVEL" -eq "1" ]; then
+ # Add "missing" for as many devices as weren't selected
+ MISSING_DEVICES=""
+ while [ $SELECTED -lt $DEV_COUNT ]; do
+ MISSING_DEVICES="$MISSING_DEVICES missing"
+ let SELECTED++
+ done
+ fi
+ # Remove partitions selected in raid${LEVEL}devs from the PARTITION list
+ db_get mdcfg/raid${LEVEL}devs
+
prune_partitions "$RET"
- db_set mdcfg/raid5sparedevs ""
+ db_set mdcfg/raid${LEVEL}sparedevs ""
SELECTED=0
if [ $SPARE_COUNT -gt 0 ]; then
FIRST=1
@@ -428,15 +319,15 @@
# That means any number less than or equal to the spare count.
while [ $SELECTED -gt $SPARE_COUNT ] || [ $FIRST -eq 1 ]; do
FIRST=0
- db_subst mdcfg/raid5sparedevs COUNT "$SPARE_COUNT"
- db_subst mdcfg/raid5sparedevs PARTITIONS "$PARTITIONS"
- db_input critical mdcfg/raid5sparedevs
+ db_subst mdcfg/raid${LEVEL}sparedevs COUNT "$SPARE_COUNT"
+ db_subst mdcfg/raid${LEVEL}sparedevs PARTITIONS "$PARTITIONS"
+ db_input critical mdcfg/raid${LEVEL}sparedevs
db_go
if [ $? -eq 30 ]; then
return
fi
- db_get mdcfg/raid5sparedevs
+ db_get mdcfg/raid${LEVEL}sparedevs
SELECTED=0
for i in $RET; do
DEVICE=$(echo $i | sed -e "s/,//")
@@ -445,13 +336,29 @@
done
fi
+ if [ "$LEVEL" -eq "10" ]; then
+ db_set mdcfg/raid10layout "n2"
+ db_input low mdcfg/raid10layout
+ db_go
+ if [ $? -eq 30 ]; then return; fi
+ db_get mdcfg/raid10layout
+ LAYOUT="--layout=$RET"
+ until echo $LAYOUT | grep -Eq "^--layout=[nfo][0-9]{1,2}$" && [ "$(echo $LAYOUT | sed s/--layout=.//)" -le "$DEV_COUNT" ]; do
+ db_input critical mdcfg/raid10layout
+ db_go
+ if [ $? -eq 30 ]; then return; fi
+ db_get mdcfg/raid10layout
+ LAYOUT="--layout=$RET"
+ done
+ fi
+
# The number of spares the user has selected
NAMED_SPARES=$SELECTED
- db_get mdcfg/raid5devs
+ db_get mdcfg/raid${LEVEL}devs
RAID_DEVICES=$(echo $RET | sed -e "s/,//g")
- db_get mdcfg/raid5sparedevs
+ db_get mdcfg/raid${LEVEL}sparedevs
SPARE_DEVICES=$(echo $RET | sed -e "s/,//g")
MISSING_SPARES=""
@@ -475,9 +382,9 @@
logger -t mdcfg "Raid devices count: $DEV_COUNT"
logger -t mdcfg "Spare devices count: $SPARE_COUNT"
log-output -t mdcfg \
- mdadm --create /dev/md$MD_NUM --auto=yes --force -R -l raid5 \
+ mdadm --create /dev/md$MD_NUM --auto=yes --force -R -l raid${LEVEL} $LAYOUT \
-n $DEV_COUNT -x $SPARE_COUNT $RAID_DEVICES \
- $SPARE_DEVICES $MISSING_SPARES
+ $MISSING_DEVICES $SPARE_DEVICES $MISSING_SPARES
}
md_mainmenu() {
@@ -503,11 +410,12 @@
### Main of script ###
# Try to load the necesarry modules.
-# Supported schemes: RAID 0, RAID 1, RAID 5
+# Supported schemes: RAID 0, RAID 1, RAID 5, RAID 6, RAID 10
depmod -a >/dev/null 2>&1
modprobe md >/dev/null 2>&1 || modprobe md-mod >/dev/null 2>&1
modprobe raid0 >/dev/null 2>&1
modprobe raid1 >/dev/null 2>&1
+modprobe raid10 >/dev/null 2>&1
# kernels >=2.6.18 have raid456
modprobe raid456 >/dev/null 2>&1 || modprobe raid5 >/dev/null 2>&1
Index: partman/partman-auto-raid/auto-raidcfg
===================================================================
--- partman/partman-auto-raid/auto-raidcfg (revision 54408)
+++ partman/partman-auto-raid/auto-raidcfg (working copy)
@@ -14,6 +14,12 @@
exit 9
fi
+ if [ "$DEV_COUNT" -lt 4 ] && ([ $RAID_TYPE = "10" ] || [ $RAID_TYPE = "6" ]); then
+ db_input critical partman-auto-raid/notenoughparts
+ db_go partman-auto-raid/notenoughparts
+ exit 9
+ fi
+
SPARE_COUNT="$3"
REQUIRED=$(($DEV_COUNT + $SPARE_COUNT))
@@ -82,13 +88,14 @@
}
# Try to load the necessary modules.
-# Supported schemes: RAID 0, RAID 1, RAID 5
+# Supported schemes: RAID 0, RAID 1, RAID 5, RAID 6, RAID 10
depmod -a 1>/dev/null 2>&1
modprobe md 1>/dev/null 2>&1 || modprobe md-mod 1>/dev/null 2>&1
modprobe raid0 >/dev/null 2>&1
modprobe raid1 1>/dev/null 2>&1
# kernels >=2.6.18 have raid456
modprobe raid456 >/dev/null 2>&1 || modprobe raid5 >/dev/null 2>&1
+modprobe raid10 >/dev/null 2>&1
mkdir -p /dev/md
# Make sure that we have md-support
Index: partman/partman-base/lib/base.sh
===================================================================
--- partman/partman-base/lib/base.sh (revision 54408)
+++ partman/partman-base/lib/base.sh (working copy)
@@ -728,7 +728,7 @@
;;
/dev/md*|/dev/md/*)
device=`echo "$1" | sed -e "s/.*md\/\?\(.*\)/\1/"`
- type=`grep "^md${device}[ :]" /proc/mdstat | sed -e "s/^.* : active raid\([[:alnum:]]\).*/\1/"`
+ type=`grep "^md${device}[ :]" /proc/mdstat | sed -e "s/^.* : active raid\([[:alnum:]]\{,2\}\).*/\1/"`
db_metaget partman/text/raid_device description
printf "$RET" ${type} ${device}
;;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/pkg-mdadm-devel/attachments/20080717/529f5a77/attachment-0001.pgp
More information about the pkg-mdadm-devel
mailing list