diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2012-09-28 23:05:15 +0530 |
---|---|---|
committer | Pranith Kumar K <pkarampu@redhat.com> | 2012-09-28 23:14:03 +0530 |
commit | 89f205689e6deed68a8daedda4679ccc10e2a881 (patch) | |
tree | 6d3df80bfd6070b44de3c463acd3669781d48c0a | |
parent | 13cfed388a19dd70984197fb14330d0277ba91e7 (diff) |
mgmt/glusterd: Avoid rounding off error in quorum calculation
Change-Id: I399bae87dc0731ee9a828306c5c411f269fb6760
BUG: 861327
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index a7a48b6b5eb..b1f7ac8a6f6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -79,6 +79,8 @@ #define NLMV4_VERSION 4 #define NLMV1_VERSION 1 +#define CEILING_POS(X) (((X)-(int)(X)) > 0 ? (int)((X)+1) : (int)(X)) + char *glusterd_sock_dir = "/tmp"; static glusterd_lock_t lock; @@ -2096,6 +2098,7 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count, char *val = NULL; double quorum_percentage = 0.0; gf_boolean_t ratio = _gf_false; + int count = 0; conf = this->private; //Start with counting self @@ -2119,10 +2122,12 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count, (void)gf_string2double(val, &quorum_percentage); } if (ratio) - *quorum_count = (inquorum_count * quorum_percentage / 100.0); + count = CEILING_POS (inquorum_count * + quorum_percentage / 100.0); else - *quorum_count = (inquorum_count * 50 / 100) + 1; + count = (inquorum_count * 50 / 100) + 1; + *quorum_count = count; ret = 0; out: return ret; |