From 89f205689e6deed68a8daedda4679ccc10e2a881 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 28 Sep 2012 23:05:15 +0530 Subject: mgmt/glusterd: Avoid rounding off error in quorum calculation Change-Id: I399bae87dc0731ee9a828306c5c411f269fb6760 BUG: 861327 Signed-off-by: Pranith Kumar K --- xlators/mgmt/glusterd/src/glusterd-utils.c | 9 +++++++-- 1 file 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; -- cgit