diff options
author | Vijay Bellur <vbellur@redhat.com> | 2012-10-01 08:23:41 -0400 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit-01.app.eng.bos.redhat.com> | 2012-10-01 08:23:41 -0400 |
commit | 2811e3e3bcb8c18a030a21cc4f654e2da55b7e22 (patch) | |
tree | e2349cdf00981753b762e8aae4e71d2859054628 | |
parent | 64b869927fa10b0dad3c1daebbfeca7bcd9a4884 (diff) | |
parent | 89f205689e6deed68a8daedda4679ccc10e2a881 (diff) |
Merge "mgmt/glusterd: Avoid rounding off error in quorum calculation"
-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; |