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.
This commit is contained in:
parent
090e16c442
commit
c943cf459a
@ -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;
|
||||
|
@ -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>
|
||||
@ -589,6 +589,18 @@ rf_paritymap_detach(RF_Raid_t *raidPtr)
|
||||
kmem_free(pm, sizeof(*pm));
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
@ -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! */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user