Index: share/man/man5/rc.conf.5
===================================================================
RCS file: /cvsroot/src/share/man/man5/rc.conf.5,v
retrieving revision 1.120.2.4
diff -u -p -r1.120.2.4 rc.conf.5
--- share/man/man5/rc.conf.5	31 Mar 2009 23:35:36 -0000	1.120.2.4
+++ share/man/man5/rc.conf.5	1 May 2010 19:38:20 -0000
@@ -276,6 +276,42 @@ If not set to
 .Sq YES ,
 and no swap devices
 are configured, the system will warn you.
+.It Sy raidframeparity_early
+.Sq YES
+or
+.Sq NO .
+Check and possibly rewrite parity on all RAIDframe devices early in the
+boot process (before
+.Xr fsck 8
+is run) and abort the boot if rewriting fails.
+.Bl -hang
+.It Em Note :
+Data on a RAID set is not protected against a component failure until
+parity is up-to-date!
+.El
+.It Sy raidframeparity_early_disks
+A space separated list of RAIDframe devices.
+Parity on these devices will be checked and possibly be rewritten early
+in the boot process as described under
+.Sy raidframeparity_early .
+Only applicable if
+.Sy raidframeparity_early
+is
+.Sq NO
+(default); otherwise all available RAIDframe devices are checked early,
+not only those listed here.
+.It Sy raidframeparity_late_disks
+A space separated list of RAIDframe devices.
+Parity on these devices will be checked and possibly be rewritten late
+in the boot process, continuing the boot after the checks have been
+initiated.
+This is the default behaviour.
+Only applicable if
+.Sy raidframeparity_early
+is
+.Sq NO
+(default); otherwise all available RAIDframe devices are checked early,
+even those listed here.
 .It Sy swapoff
 .Sq YES
 or
Index: etc/defaults/rc.conf
===================================================================
RCS file: /cvsroot/src/etc/defaults/rc.conf,v
retrieving revision 1.95.2.5
diff -u -p -r1.95.2.5 rc.conf
--- etc/defaults/rc.conf	18 Dec 2009 06:09:56 -0000	1.95.2.5
+++ etc/defaults/rc.conf	1 May 2010 19:38:19 -0000
@@ -92,6 +92,13 @@ ccd=YES
 #
 raidframe=YES
 
+# When and how to check and possibly rewrite RAIDframe parity.
+#
+raidframeparity_early=NO	# Set to YES to check parity on all RAIDframe
+				# devices early in the boot process and not to
+				# continue until it completes successfully.
+				# For more fine-grained options see rc.conf(5).
+
 # Crypto file system.
 #
 cgd=YES
Index: etc/rc.d/raidframe
===================================================================
RCS file: /cvsroot/src/etc/rc.d/raidframe,v
retrieving revision 1.9
diff -u -p -r1.9 raidframe
--- etc/rc.d/raidframe	13 Aug 2004 18:08:03 -0000	1.9
+++ etc/rc.d/raidframe	1 May 2010 19:38:20 -0000
@@ -4,6 +4,7 @@
 #
 
 # PROVIDE: disks
+# BEFORE:  raidframeparity_early
 
 $_rc_subr_loaded . /etc/rc.subr
 
Index: etc/rc.d/raidframeparity
===================================================================
RCS file: /cvsroot/src/etc/rc.d/raidframeparity,v
retrieving revision 1.3
diff -u -p -r1.3 raidframeparity
--- etc/rc.d/raidframeparity	11 Oct 2004 15:00:51 -0000	1.3
+++ etc/rc.d/raidframeparity	1 May 2010 19:38:20 -0000
@@ -9,14 +9,28 @@ $_rc_subr_loaded . /etc/rc.subr
 
 name="raidframeparity"
 start_cmd="raidframeparity_start"
+start_precmd="raidframeparity_prestart"
 stop_cmd=":"
 
+raidframeparity_prestart()
+{
+	checkyesno raidframeparity_early && return 1
+
+	if [ -z "$raidframeparity_late_disks" ]; then
+		if [ -z "$raidframeparity_early_disks" ]; then
+			raidframeparity_late_disks=$(sysctl -n hw.disknames)
+		else
+			return 1
+		fi
+	fi
+}
+
 raidframeparity_start()
 {
 	# Initiate parity/mirror reconstruction as needed, in the background.
 	#
 	(
-		for dev in $(sysctl -n hw.disknames); do
+		for dev in $raidframeparity_late_disks; do
 			case $dev in
 			raid[0-9]*)
 				raidctl -P $dev
--- /dev/null	2010-05-01 21:54:11.000000000 +0200
+++ etc/rc.d/raidframeparity_early	2009-06-24 16:50:56.000000000 +0200
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# $NetBSD$
+#
+
+# PROVIDE: disks raidframeparity_early
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="raidframeparity_early"
+start_cmd="raidframeparity_early_start"
+start_precmd="raidframeparity_early_prestart"
+stop_cmd=":"
+
+raidframeparity_early_prestart()
+{
+	if checkyesno raidframeparity_early; then
+		raidframeparity_early_disks=$(sysctl -n hw.disknames)
+	fi
+
+	if [ -z "$raidframeparity_early_disks" ]; then
+		return 1
+	fi
+}
+
+raidframeparity_early_start()
+{
+	# Initiate parity/mirror reconstruction as needed,
+	# aborting boot if this fails.
+	#
+	for dev in $raidframeparity_early_disks; do
+		case $dev in
+		raid[0-9]*)
+			raidctl -v -P $dev || stop_boot
+			;;
+		esac
+	done
+}
+
+load_rc_config $name
+run_rc_command "$1"
Index: etc/rc.d/Makefile
===================================================================
RCS file: /cvsroot/src/etc/rc.d/Makefile,v
retrieving revision 1.68.2.4
diff -u -p -r1.68.2.4 Makefile
--- etc/rc.d/Makefile	10 May 2009 21:32:57 -0000	1.68.2.4
+++ etc/rc.d/Makefile	1 May 2010 19:38:19 -0000
@@ -24,7 +24,7 @@ CONFIGFILES=\
 		named ndbootd network newsyslog nfsd nfslocking ntpd ntpdate \
 		perusertmp pf pf_boot pflogd poffd postfix powerd ppp pwcheck \
 		quota \
-		racoon rpcbind raidframe raidframeparity rarpd rbootd rndctl \
+		racoon rpcbind raidframe raidframeparity raidframeparity_early rarpd rbootd rndctl \
 		root route6d routed rtadvd rtclocaltime rtsold rwho \
 		savecore screenblank sdpd securelevel sshd \
 		staticroute swap1 swap2 sysctl sysdb syslogd \
Index: etc/mtree/special
===================================================================
RCS file: /cvsroot/src/etc/mtree/special,v
retrieving revision 1.121.2.3
diff -u -p -r1.121.2.3 special
--- etc/mtree/special	18 Sep 2009 02:01:38 -0000	1.121.2.3
+++ etc/mtree/special	1 May 2010 19:38:19 -0000
@@ -254,6 +254,7 @@
 ./etc/rc.d/racoon		type=file mode=0555
 ./etc/rc.d/raidframe		type=file mode=0555
 ./etc/rc.d/raidframeparity	type=file mode=0555
+./etc/rc.d/raidframeparity_early type=file mode=0555
 ./etc/rc.d/rarpd		type=file mode=0555
 ./etc/rc.d/rbootd		type=file mode=0555
 ./etc/rc.d/rndctl		type=file mode=0555
Index: distrib/sets/lists/etc/mi
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/etc/mi,v
retrieving revision 1.200.2.6
diff -u -p -r1.200.2.6 mi
--- distrib/sets/lists/etc/mi	15 Sep 2009 06:01:39 -0000	1.200.2.6
+++ distrib/sets/lists/etc/mi	1 May 2010 19:38:19 -0000
@@ -243,6 +243,7 @@
 ./etc/rc.d/racoon				etc-net-rc
 ./etc/rc.d/raidframe				etc-sys-rc
 ./etc/rc.d/raidframeparity			etc-sys-rc
+./etc/rc.d/raidframeparity_early		etc-sys-rc
 ./etc/rc.d/rarpd				etc-bootserver-rc
 ./etc/rc.d/rbootd				etc-bootserver-rc
 ./etc/rc.d/rndctl				etc-sys-rc
Index: usr.sbin/postinstall/postinstall
===================================================================
RCS file: /cvsroot/src/usr.sbin/postinstall/postinstall,v
retrieving revision 1.76.2.24
diff -u -p -r1.76.2.24 postinstall
--- usr.sbin/postinstall/postinstall	11 Jan 2010 00:09:45 -0000	1.76.2.24
+++ usr.sbin/postinstall/postinstall	1 May 2010 20:00:50 -0000
@@ -1072,7 +1072,7 @@ do_rc()
 		named ndbootd network newsyslog nfsd nfslocking ntpd ntpdate \
 		perusertmp pf pf_boot pflogd poffd postfix powerd ppp pwcheck \
 		quota \
-		racoon rpcbind raidframe raidframeparity rarpd rbootd rndctl \
+		racoon rpcbind raidframe raidframeparity raidframeparity_early rarpd rbootd rndctl \
 		root route6d routed rtadvd rtclocaltime rtsold rwho \
 		savecore screenblank sdpd securelevel sshd \
 		staticroute swap1 swap2 sysctl sysdb syslogd \
