summaryrefslogtreecommitdiffstats
path: root/sys/dev/vinum
diff options
context:
space:
mode:
authorle <le@FreeBSD.org>2004-02-04 22:29:52 +0000
committerle <le@FreeBSD.org>2004-02-04 22:29:52 +0000
commit2e81345a929ffe5f5902c426401d4483222ff2ba (patch)
tree231ca53217829e0ec61b3545027340c3cd3495b3 /sys/dev/vinum
parent27c73ac133cce8b7ad1bf63fc1de1636787b891b (diff)
downloadFreeBSD-src-2e81345a929ffe5f5902c426401d4483222ff2ba.zip
FreeBSD-src-2e81345a929ffe5f5902c426401d4483222ff2ba.tar.gz
When creating raid5 or striped plexes, avoid falling out of bounds
when checking the given stripe size. Also move the code a bit around to avoid duplication. Approved by: joerg (mentor)
Diffstat (limited to 'sys/dev/vinum')
-rw-r--r--sys/dev/vinum/vinumconfig.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/sys/dev/vinum/vinumconfig.c b/sys/dev/vinum/vinumconfig.c
index 8227485..f556f77 100644
--- a/sys/dev/vinum/vinumconfig.c
+++ b/sys/dev/vinum/vinumconfig.c
@@ -1281,7 +1281,9 @@ config_plex(int update)
int namedplexno;
enum plexstate state = plex_init; /* state to set at end */
int preferme; /* set if we want to be preferred access */
+ int stripesize;
+ stripesize = 0;
current_plex = -1; /* forget the previous plex */
preferme = 0; /* nothing special yet */
plexno = get_empty_plex(); /* allocate a plex */
@@ -1339,52 +1341,53 @@ config_plex(int update)
case kw_striped:
{
- int stripesize = sizespec(token[++parameter]);
-
plex->organization = plex_striped;
- if (stripesize % DEV_BSIZE != 0) /* not a multiple of block size, */
- throw_rude_remark(EINVAL, "plex %s: stripe size %d not a multiple of sector size",
- plex->name,
- stripesize);
+
+ if (++parameter >= tokens) /* No stripe size specified. */
+ stripesize = 0;
else
- plex->stripesize = stripesize / DEV_BSIZE;
+ stripesize = sizespec(token[parameter]);
+
break;
}
case kw_raid4:
{
- int stripesize = sizespec(token[++parameter]);
-
plex->organization = plex_raid4;
- if (stripesize % DEV_BSIZE != 0) /* not a multiple of block size, */
- throw_rude_remark(EINVAL, "plex %s: stripe size %d not a multiple of sector size",
- plex->name,
- stripesize);
+
+ if (++parameter >= tokens) /* No stripe size specified. */
+ stripesize = 0;
else
- plex->stripesize = stripesize / DEV_BSIZE;
+ stripesize = sizespec(token[parameter]);
+
break;
}
case kw_raid5:
{
- int stripesize = sizespec(token[++parameter]);
-
plex->organization = plex_raid5;
- if (stripesize % DEV_BSIZE != 0) /* not a multiple of block size, */
- throw_rude_remark(EINVAL, "plex %s: stripe size %d not a multiple of sector size",
- plex->name,
- stripesize);
+
+ if (++parameter >= tokens) /* No stripe size specified. */
+ stripesize = 0;
else
- plex->stripesize = stripesize / DEV_BSIZE;
+ stripesize = sizespec(token[parameter]);
+
break;
}
default:
throw_rude_remark(EINVAL, "Invalid plex organization");
}
- if (isstriped(plex)
- && (plex->stripesize == 0)) /* didn't specify a valid stripe size */
- throw_rude_remark(EINVAL, "Need a stripe size parameter");
+ if (isstriped(plex)) {
+ if (stripesize == 0) /* didn't specify a valid stripe size */
+ throw_rude_remark(EINVAL, "Need a stripe size parameter");
+ else if (stripesize % DEV_BSIZE != 0)
+ throw_rude_remark(EINVAL, "plex %s: stripe size %d not a multiple of sector size",
+ plex->name,
+ stripesize);
+ else
+ plex->stripesize = stripesize / DEV_BSIZE;
+ }
break;
/*
OpenPOWER on IntegriCloud