gfs2-utils: RHEL7 - libgfs2: Fix off-by-one in lgfs2_rgrps_plan
Andrew Price
andyp at fedoraproject.org
Mon Sep 8 17:33:31 UTC 2014
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=4980ba91fbbdd5ab9718112e42a0b71e57c98aec
Commit: 4980ba91fbbdd5ab9718112e42a0b71e57c98aec
Parent: 2e09a76e3cf522b4fd85f8008af522670c072720
Author: Andrew Price <anprice at redhat.com>
AuthorDate: Thu Apr 3 06:25:17 2014 -0500
Committer: Andrew Price <anprice at redhat.com>
CommitterDate: Thu Jul 24 17:15:39 2014 +0100
libgfs2: Fix off-by-one in lgfs2_rgrps_plan
We were making plans based on an extra resource group but not adding the extra
one to the count. Make sure the count is incremented appropriately.
Signed-off-by: Andrew Price <anprice at redhat.com>
---
gfs2/libgfs2/rgrp.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index cae7a32..d70dfc5 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -299,7 +299,8 @@ uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32_t tgts
/* Spread the adjustment required to fit a new rgrp at the end
over all of the rgrps so that we don't end with a single
tiny one. */
- while (((rgs->plan[0].len - adj) * (rgs->plan[0].num + 1)) >= space)
+ rgs->plan[0].num++;
+ while (((rgs->plan[0].len - adj) * (rgs->plan[0].num)) >= space)
rgs->plan[0].len -= adj;
/* We've adjusted the size of the rgrps down as far as we can
@@ -313,7 +314,7 @@ uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32_t tgts
rgs->plan[1].num = 0;
while (((rgs->plan[0].len * rgs->plan[0].num) +
- (rgs->plan[1].len * rgs->plan[1].num)) > space) {
+ (rgs->plan[1].len * rgs->plan[1].num)) >= space) {
/* Total number of rgrps stays constant now. We just
need to shift some weight around */
rgs->plan[0].num--;
More information about the cluster-commits
mailing list