summaryrefslogtreecommitdiff
path: root/sys/dev/raidframe
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/raidframe')
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c12
-rw-r--r--sys/dev/raidframe/rf_paritymap.c18
-rw-r--r--sys/dev/raidframe/rf_paritymap.h3
3 files changed, 27 insertions, 6 deletions
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index 2aaa6cd7ad1..2d01432ad7e 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -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 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
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 @@ raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
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;
diff --git a/sys/dev/raidframe/rf_paritymap.c b/sys/dev/raidframe/rf_paritymap.c
index c5e4d3966a0..187b7e8129a 100644
--- a/sys/dev/raidframe/rf_paritymap.c
+++ b/sys/dev/raidframe/rf_paritymap.c
@@ -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 @@ rf_paritymap_detach(RF_Raid_t *raidPtr)
}
/*
+ * 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 @@ rf_paritymap_attach(RF_Raid_t *raidPtr, int force)
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;
}
diff --git a/sys/dev/raidframe/rf_paritymap.h b/sys/dev/raidframe/rf_paritymap.h
index 059a8828559..91b49c89121 100644
--- a/sys/dev/raidframe/rf_paritymap.h
+++ b/sys/dev/raidframe/rf_paritymap.h
@@ -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_rewrite(struct rf_paritymap *);
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! */