Module Name:    src
Committed By:   jld
Date:           Sun Mar 14 21:11:41 UTC 2010

Modified Files:
        src/sys/dev/raidframe: rf_netbsdkintf.c rf_paritymap.c rf_paritymap.h

Log Message:
For RAID sets which have no parity (i.e., RAID level 0) and therefore can
never have a parity map, make the parity map ioctls fail with EINVAL.

This makes `raidctl -m` print a scary-looking error on such sets, which
is an improvement over the previous behavior of falsely claiming that
the parity map would be enabled on the next configuration.


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/raidframe/rf_paritymap.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/raidframe/rf_paritymap.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.272 src/sys/dev/raidframe/rf_netbsdkintf.c:1.273
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.272	Mon Mar  1 14:51:58 2010
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Sun Mar 14 21:11:41 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.272 2010/03/01 14:51:58 oster Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.273 2010/03/14 21:11:41 jld Exp $	*/
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -139,7 +139,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.272 2010/03/01 14:51:58 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.273 2010/03/14 21:11:41 jld Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1506,11 +1506,15 @@
 		return (0);
 
 	case RAIDFRAME_PARITYMAP_STATUS:
+		if (rf_paritymap_ineligible(raidPtr))
+			return EINVAL;
 		rf_paritymap_status(raidPtr->parity_map,
 		    (struct rf_pmstat *)data);
 		return 0;
 
 	case RAIDFRAME_PARITYMAP_SET_PARAMS:
+		if (rf_paritymap_ineligible(raidPtr))
+			return EINVAL;
 		if (raidPtr->parity_map == NULL)
 			return ENOENT; /* ??? */
 		if (0 != rf_paritymap_set_params(raidPtr->parity_map, 
@@ -1519,10 +1523,14 @@
 		return 0;
 
 	case RAIDFRAME_PARITYMAP_GET_DISABLE:
+		if (rf_paritymap_ineligible(raidPtr))
+			return EINVAL;
 		*(int *) data = rf_paritymap_get_disable(raidPtr);
 		return 0;
 
 	case RAIDFRAME_PARITYMAP_SET_DISABLE:
+		if (rf_paritymap_ineligible(raidPtr))
+			return EINVAL;
 		rf_paritymap_set_disable(raidPtr, *(int *)data);
 		/* XXX should errors be passed up? */
 		return 0;

Index: src/sys/dev/raidframe/rf_paritymap.c
diff -u src/sys/dev/raidframe/rf_paritymap.c:1.4 src/sys/dev/raidframe/rf_paritymap.c:1.5
--- src/sys/dev/raidframe/rf_paritymap.c:1.4	Wed Mar  3 14:23:27 2010
+++ src/sys/dev/raidframe/rf_paritymap.c	Sun Mar 14 21:11:41 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_paritymap.c,v 1.4 2010/03/03 14:23:27 oster Exp $ */
+/* $NetBSD: rf_paritymap.c,v 1.5 2010/03/14 21:11:41 jld Exp $ */
 
 /*-
  * Copyright (c) 2009 Jed Davis.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.4 2010/03/03 14:23:27 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_paritymap.c,v 1.5 2010/03/14 21:11:41 jld Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -590,6 +590,18 @@
 }
 
 /*
+ * Is this RAID set ineligible for parity-map use due to not actually
+ * having any parity?  (If so, rf_paritymap_attach is a no-op, but
+ * rf_paritymap_{get,set}_disable will still pointlessly act on the
+ * component labels.)
+ */
+int
+rf_paritymap_ineligible(RF_Raid_t *raidPtr)
+{
+	return raidPtr->Layout.map->faultsTolerated == 0;
+}
+
+/*
  * Attach a parity map to a RAID set if appropriate.  Includes
  * configure-time processing of parity-map fields of component label.
  */
@@ -604,7 +616,7 @@
 	u_int flags, regions;
 	struct rf_pmparams params;
 
-	if (raidPtr->Layout.map->faultsTolerated == 0) {
+	if (rf_paritymap_ineligible(raidPtr)) {
 		/* There isn't any parity. */
 		return;
 	}

Index: src/sys/dev/raidframe/rf_paritymap.h
diff -u src/sys/dev/raidframe/rf_paritymap.h:1.1 src/sys/dev/raidframe/rf_paritymap.h:1.2
--- src/sys/dev/raidframe/rf_paritymap.h:1.1	Tue Nov 17 18:54:26 2009
+++ src/sys/dev/raidframe/rf_paritymap.h	Sun Mar 14 21:11:41 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_paritymap.h,v 1.1 2009/11/17 18:54:26 jld Exp $ */
+/* $NetBSD: rf_paritymap.h,v 1.2 2010/03/14 21:11:41 jld Exp $ */
 
 /*-
  * Copyright (c) 2009 Jed Davis.
@@ -112,6 +112,7 @@
 int rf_paritymap_merge(struct rf_paritymap_ondisk *,
     struct rf_paritymap_ondisk *);
 
+int rf_paritymap_ineligible(RF_Raid_t *);
 void rf_paritymap_attach(RF_Raid_t *, int);
 void rf_paritymap_detach(RF_Raid_t *); /* Not while the RAID is live! */
 

Reply via email to