diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2012-09-27 00:49:54 +0530 |
---|---|---|
committer | Pranith Kumar K <pkarampu@redhat.com> | 2012-09-27 10:41:19 +0530 |
commit | 13cfed388a19dd70984197fb14330d0277ba91e7 (patch) | |
tree | 8e86f3cc4f441b3804741ee9dc6dbb9288269b12 /libglusterfs | |
parent | c8f9437b6ef507a4dc7fe03aa32a9fbf220d09f6 (diff) |
mgmt/glusterd: Implementation of server-side quorum.
Feature-page:
http://www.gluster.org/community/documentation/index.php/Features/Server-quorum
Change-Id: Ifec0f1a697d390a29ba447a09750602fea1b3a4b
BUG: 840122
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/common-utils.c | 7 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.h | 2 | ||||
-rw-r--r-- | libglusterfs/src/options.c | 35 | ||||
-rw-r--r-- | libglusterfs/src/options.h | 8 |
4 files changed, 27 insertions, 25 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 7e7eb461409..7662b7f971a 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -624,11 +624,10 @@ gf_string2time (const char *str, uint32_t *n) return 0; } - int -gf_string2percent (const char *str, uint32_t *n) +gf_string2percent (const char *str, double *n) { - unsigned long value = 0; + double value = 0; char *tail = NULL; int old_errno = 0; const char *s = NULL; @@ -649,7 +648,7 @@ gf_string2percent (const char *str, uint32_t *n) old_errno = errno; errno = 0; - value = strtol (str, &tail, 0); + value = strtod (str, &tail); if (errno == ERANGE || errno == EINVAL) return -1; diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index d5880291250..0c6d7ef7a5d 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -442,7 +442,7 @@ int gf_string2percent_or_bytesize (const char *str, uint64_t *n, gf_boolean_t *is_percent); int gf_string2boolean (const char *str, gf_boolean_t *b); -int gf_string2percent (const char *str, uint32_t *n); +int gf_string2percent (const char *str, double *n); int gf_string2time (const char *str, uint32_t *n); int gf_lockfd (int fd); diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c index 0cec59fdb06..f4cb0425893 100644 --- a/libglusterfs/src/options.c +++ b/libglusterfs/src/options.c @@ -53,7 +53,6 @@ out: return ret; } - static int xlator_option_validate_int (xlator_t *xl, const char *key, const char *value, volume_option_t *opt, char **op_errstr) @@ -282,10 +281,9 @@ static int xlator_option_validate_percent (xlator_t *xl, const char *key, const char *value, volume_option_t *opt, char **op_errstr) { - int ret = -1; - char errstr[256]; - uint32_t percent = 0; - + double percent = 0; + int ret = -1; + char errstr[256]; /* Check if the value is valid percentage */ if (gf_string2percent (value, &percent) != 0) { @@ -296,9 +294,9 @@ xlator_option_validate_percent (xlator_t *xl, const char *key, const char *value goto out; } - if ((percent < 0) || (percent > 100)) { + if ((percent < 0.0) || (percent > 100.0)) { snprintf (errstr, 256, - "'%d' in 'option %s %s' is out of range [0 - 100]", + "'%lf' in 'option %s %s' is out of range [0 - 100]", percent, key, value); gf_log (xl->name, GF_LOG_ERROR, "%s", errstr); goto out; @@ -1013,19 +1011,24 @@ xl_by_name (char *in, xlator_t **out) static int -pc_or_size (char *in, uint64_t *out) +pc_or_size (char *in, double *out) { - uint32_t pc = 0; + double pc = 0; int ret = 0; + uint64_t size = 0; if (gf_string2percent (in, &pc) == 0) { - if (pc > 100) { - ret = gf_string2bytesize (in, out); + if (pc > 100.0) { + ret = gf_string2bytesize (in, &size); + if (!ret) + *out = size; } else { *out = pc; } } else { - ret = gf_string2bytesize (in, out); + ret = gf_string2bytesize (in, &size); + if (!ret) + *out = size; } return ret; } @@ -1037,8 +1040,8 @@ DEFINE_INIT_OPT(int64_t, int64, gf_string2int64); DEFINE_INIT_OPT(uint32_t, uint32, gf_string2uint32); DEFINE_INIT_OPT(int32_t, int32, gf_string2int32); DEFINE_INIT_OPT(uint64_t, size, gf_string2bytesize); -DEFINE_INIT_OPT(uint32_t, percent, gf_string2percent); -DEFINE_INIT_OPT(uint64_t, percent_or_size, pc_or_size); +DEFINE_INIT_OPT(double, percent, gf_string2percent); +DEFINE_INIT_OPT(double, percent_or_size, pc_or_size); DEFINE_INIT_OPT(gf_boolean_t, bool, gf_string2boolean); DEFINE_INIT_OPT(xlator_t *, xlator, xl_by_name); DEFINE_INIT_OPT(char *, path, not_null); @@ -1051,8 +1054,8 @@ DEFINE_RECONF_OPT(int64_t, int64, gf_string2int64); DEFINE_RECONF_OPT(uint32_t, uint32, gf_string2uint32); DEFINE_RECONF_OPT(int32_t, int32, gf_string2int32); DEFINE_RECONF_OPT(uint64_t, size, gf_string2bytesize); -DEFINE_RECONF_OPT(uint32_t, percent, gf_string2percent); -DEFINE_RECONF_OPT(uint64_t, percent_or_size, pc_or_size); +DEFINE_RECONF_OPT(double, percent, gf_string2percent); +DEFINE_RECONF_OPT(double, percent_or_size, pc_or_size); DEFINE_RECONF_OPT(gf_boolean_t, bool, gf_string2boolean); DEFINE_RECONF_OPT(xlator_t *, xlator, xl_by_name); DEFINE_RECONF_OPT(char *, path, not_null); diff --git a/libglusterfs/src/options.h b/libglusterfs/src/options.h index 01d2a9d5f1b..f0acb33688d 100644 --- a/libglusterfs/src/options.h +++ b/libglusterfs/src/options.h @@ -95,8 +95,8 @@ DECLARE_INIT_OPT(int64_t, int64); DECLARE_INIT_OPT(uint32_t, uint32); DECLARE_INIT_OPT(int32_t, int32); DECLARE_INIT_OPT(uint64_t, size); -DECLARE_INIT_OPT(uint32_t, percent); -DECLARE_INIT_OPT(uint64_t, percent_or_size); +DECLARE_INIT_OPT(double, percent); +DECLARE_INIT_OPT(double, percent_or_size); DECLARE_INIT_OPT(gf_boolean_t, bool); DECLARE_INIT_OPT(xlator_t *, xlator); DECLARE_INIT_OPT(char *, path); @@ -173,8 +173,8 @@ DECLARE_RECONF_OPT(int64_t, int64); DECLARE_RECONF_OPT(uint32_t, uint32); DECLARE_RECONF_OPT(int32_t, int32); DECLARE_RECONF_OPT(uint64_t, size); -DECLARE_RECONF_OPT(uint32_t, percent); -DECLARE_RECONF_OPT(uint64_t, percent_or_size); +DECLARE_RECONF_OPT(double, percent); +DECLARE_RECONF_OPT(double, percent_or_size); DECLARE_RECONF_OPT(gf_boolean_t, bool); DECLARE_RECONF_OPT(xlator_t *, xlator); DECLARE_RECONF_OPT(char *, path); |