diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2019-09-05 16:12:39 +0530 |
---|---|---|
committer | Pranith Kumar K <pkarampu@redhat.com> | 2019-09-08 09:09:52 +0530 |
commit | ea95631ff47c8048f039faedbc0faa918c4e165a (patch) | |
tree | 5442f13643bb637dc7011617815b726362a8bc2d /xlators/mgmt/glusterd/src | |
parent | 6bf09ecbe8203d0f8c020e6b0b55202e91e216c9 (diff) |
cluster/ec: quorum-count implementation
fixes: #721
Change-Id: I5333540e3c635ccf441cf1f4696e4c8986e38ea8
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index 2ed8d48be59..e4427069263 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -647,6 +647,42 @@ out: } static int +validate_disperse_quorum_count(glusterd_volinfo_t *volinfo, dict_t *dict, + char *key, char *value, char **op_errstr) +{ + int ret = -1; + int quorum_count = 0; + int data_count = 0; + + ret = gf_string2int(value, &quorum_count); + if (ret) { + gf_asprintf(op_errstr, + "%s is not an integer. %s expects a " + "valid integer value.", + value, key); + goto out; + } + + if (volinfo->type != GF_CLUSTER_TYPE_DISPERSE) { + gf_asprintf(op_errstr, "Cannot set %s for a non-disperse volume.", key); + ret = -1; + goto out; + } + + data_count = volinfo->disperse_count - volinfo->redundancy_count; + if (quorum_count < data_count || quorum_count > volinfo->disperse_count) { + gf_asprintf(op_errstr, "%d for %s is out of range [%d - %d]", + quorum_count, key, data_count, volinfo->disperse_count); + ret = -1; + goto out; + } + + ret = 0; +out: + return ret; +} + +static int validate_parallel_readdir(glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value, char **op_errstr) { @@ -2917,6 +2953,16 @@ struct volopt_map_entry glusterd_volopt_map[] = { .type = NO_DOC, .op_version = GD_OP_VERSION_3_13_0, .flags = VOLOPT_FLAG_CLIENT_OPT}, + {.key = "disperse.quorum-count", + .voltype = "cluster/disperse", + .type = NO_DOC, + .op_version = GD_OP_VERSION_8_0, + .validate_fn = validate_disperse_quorum_count, + .description = "This option can be used to define how many successes on" + "the bricks constitute a success to the application. This" + " count should be in the range" + "[disperse-data-count, disperse-count] (inclusive)", + .flags = VOLOPT_FLAG_CLIENT_OPT}, { .key = "features.sdfs", .voltype = "features/sdfs", |