update_plex_config: Eliminate a potential divide-by-zero.
Tripped-over-by: Karl Pielorz <kpielorz@tdx.co.uk>
This commit is contained in:
parent
4a10e91653
commit
d85bfa1067
|
@ -1826,19 +1826,21 @@ update_plex_config(int plexno, int diskconfig)
|
|||
* the stripe size. If not, trim off the end
|
||||
* of each subdisk and return it to the drive.
|
||||
*/
|
||||
remainder = (int) (plex->length % ((u_int64_t) plex->stripesize * data_sds)); /* are we exact? */
|
||||
if (remainder) { /* no */
|
||||
log(LOG_INFO, "vinum: removing %d blocks of partial stripe at the end of %s\n",
|
||||
remainder,
|
||||
plex->name);
|
||||
plex->length -= remainder; /* shorten the plex */
|
||||
remainder /= data_sds; /* spread the remainder amongst the sds */
|
||||
for (sdno = 0; sdno < plex->subdisks; sdno++) {
|
||||
sd = &SD[plex->sdnos[sdno]]; /* point to the subdisk */
|
||||
return_drive_space(sd->driveno, /* return the space */
|
||||
sd->driveoffset + sd->sectors - remainder,
|
||||
remainder);
|
||||
sd->sectors -= remainder; /* and shorten it */
|
||||
if (plex->length > 0) {
|
||||
remainder = (int) (plex->length % ((u_int64_t) plex->stripesize * data_sds)); /* are we exact? */
|
||||
if (remainder) { /* no */
|
||||
log(LOG_INFO, "vinum: removing %d blocks of partial stripe at the end of %s\n",
|
||||
remainder,
|
||||
plex->name);
|
||||
plex->length -= remainder; /* shorten the plex */
|
||||
remainder /= data_sds; /* spread the remainder amongst the sds */
|
||||
for (sdno = 0; sdno < plex->subdisks; sdno++) {
|
||||
sd = &SD[plex->sdnos[sdno]]; /* point to the subdisk */
|
||||
return_drive_space(sd->driveno, /* return the space */
|
||||
sd->driveoffset + sd->sectors - remainder,
|
||||
remainder);
|
||||
sd->sectors -= remainder; /* and shorten it */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue