diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/afr/src/afr.c | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 45 |
2 files changed, 42 insertions, 6 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c index aee150123ba..10b6c2f9463 100644 --- a/xlators/cluster/afr/src/afr.c +++ b/xlators/cluster/afr/src/afr.c @@ -1035,8 +1035,9 @@ struct volume_options options[] = { .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC, .tags = {"replicate"}, /*.option = quorum-count*/ + /*.validate_fn = validate_quorum_count*/ .description = "If quorum-type is \"fixed\" only allow writes if " - "this many bricks or present. Other quorum types " + "this many bricks are present. Other quorum types " "will OVERWRITE this value.", }, { .key = {"quorum-reads"}, diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 2e216159d03..4f8e1e3be0e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -847,6 +847,40 @@ out: } static int +validate_quorum_count (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) +{ + int ret = 0; + xlator_t *this = NULL; + int q_count = 0; + + this = THIS; + GF_ASSERT (this); + + ret = gf_string2int (value, &q_count); + if (ret) { + gf_asprintf (op_errstr, "%s is not an integer. %s expects a " + "valid integer value.", value, key); + goto out; + } + + if (q_count < 1 || q_count > volinfo->replica_count) { + gf_asprintf (op_errstr, "%d in %s %d is out of range [1 - %d]", + q_count, key, q_count, volinfo->replica_count); + ret = -1; + } + +out: + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_INVALID_ENTRY, "%s", + *op_errstr); + } + gf_msg_debug (this->name, 0, "Returning %d", ret); + + return ret; +} + +static int validate_subvols_per_directory (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value, char **op_errstr) { @@ -1456,11 +1490,12 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = 1, .flags = VOLOPT_FLAG_CLIENT_OPT }, - { .key = "cluster.quorum-count", - .voltype = "cluster/replicate", - .option = "quorum-count", - .op_version = 1, - .flags = VOLOPT_FLAG_CLIENT_OPT + { .key = "cluster.quorum-count", + .voltype = "cluster/replicate", + .option = "quorum-count", + .op_version = 1, + .validate_fn = validate_quorum_count, + .flags = VOLOPT_FLAG_CLIENT_OPT }, { .key = "cluster.choose-local", .voltype = "cluster/replicate", |