diff options
author | Lukas Ertl <le@FreeBSD.org> | 2004-02-04 22:29:52 +0000 |
---|---|---|
committer | Lukas Ertl <le@FreeBSD.org> | 2004-02-04 22:29:52 +0000 |
commit | 3a1ab63eb7f1b83ac799c8e94544ef7a20493eb4 (patch) | |
tree | 231ca53217829e0ec61b3545027340c3cd3495b3 /sys | |
parent | 0804ed5acceec1fc8279a4e0af845a763058f174 (diff) | |
download | src-3a1ab63eb7f1b83ac799c8e94544ef7a20493eb4.tar.gz src-3a1ab63eb7f1b83ac799c8e94544ef7a20493eb4.zip |
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)
Notes
Notes:
svn path=/head/; revision=125458
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/vinum/vinumconfig.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/sys/dev/vinum/vinumconfig.c b/sys/dev/vinum/vinumconfig.c index 8227485f11a8..f556f77b7dda 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; /* |