summaryrefslogtreecommitdiff
path: root/sys/dev/softraid.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2009-07-12 21:46:37 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2009-07-12 21:46:37 +0000
commitb86e0ef9cf44f68bef45e008d65d40c52c090895 (patch)
tree2179477221a4edab7b4d37fd352e3fb4c90d6807 /sys/dev/softraid.c
parent30c4ab43dd83a0d356d40763e81d4af798d13f45 (diff)
Fix rebuild percentage so that it ranges from 0-99% rather than 1-100%.
ok marco@
Diffstat (limited to 'sys/dev/softraid.c')
-rw-r--r--sys/dev/softraid.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 1cf955190d8..89c34d94e34 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.165 2009/07/12 16:31:56 jsing Exp $ */
+/* $OpenBSD: softraid.c,v 1.166 2009/07/12 21:46:36 jsing Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -2013,7 +2013,11 @@ sr_ioctl_vol(struct sr_softc *sc, struct bioc_vol *bv)
if (bv->bv_status == BIOC_SVREBUILD) {
sz = sd->sd_meta->ssdi.ssd_size;
rb = sd->sd_meta->ssd_rebuild;
- bv->bv_percent = 100 - ((sz * 100 - rb * 100) / sz);
+ if (rb > 0)
+ bv->bv_percent = 100 -
+ ((sz * 100 - rb * 100) / sz) - 1;
+ else
+ bv->bv_percent = 0;
}
strlcpy(bv->bv_dev, sd->sd_meta->ssd_devname,
sizeof(bv->bv_dev));
@@ -3578,7 +3582,10 @@ sr_rebuild_thread(void *arg)
*/
psz = sd->sd_meta->ssdi.ssd_size;
rb = sd->sd_meta->ssd_rebuild;
- percent = 100 - ((psz * 100 - rb * 100) / psz);
+ if (rb > 0)
+ percent = 100 - ((psz * 100 - rb * 100) / psz) - 1;
+ else
+ percent = 0;
printf("%s: resuming rebuild on %s at %llu%%\n",
DEVNAME(sc), sd->sd_meta->ssd_devname, percent);
}
@@ -3675,7 +3682,10 @@ queued:
/* save metadata every percent */
psz = sd->sd_meta->ssdi.ssd_size;
rb = sd->sd_meta->ssd_rebuild;
- percent = 100 - ((psz * 100 - rb * 100) / psz);
+ if (rb > 0)
+ percent = 100 - ((psz * 100 - rb * 100) / psz) - 1;
+ else
+ percent = 0;
if (percent != old_percent && blk != whole_blk) {
if (sr_meta_save(sd, SR_META_DIRTY))
printf("%s: could not save metadata to %s\n",