diff options
author | Gaurav Yadav <gyadav@redhat.com> | 2017-01-31 16:14:46 +0530 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2017-03-06 11:51:54 -0500 |
commit | c618de80696c4572fad9e28f0454e63ebb2ff4ed (patch) | |
tree | 6b1004cc9d65261aa035f80fbe727cf94c442748 /xlators | |
parent | b7ba77ab3ffb641d06223f7af5145d3d670b032a (diff) |
glusterd : Fix for replicate and disperse volume option
While setting volume option(disperse-shd-max-threads) for
replicate volume and volume option(cluster-shd-max-threads)
for disperse volume, glusterd is not validating volume options
and setting all the values irrespective of proper validation
for disperse-shd-max-threads and cluster-shd-max-threads
Change-Id: Ic88815ad49e901e74ffc042170f5caabf7c17a89
BUG: 1417588
Signed-off-by: Gaurav Yadav <gyadav@redhat.com>
Reviewed-on: https://review.gluster.org/16489
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-messages.h | 8 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 35 |
2 files changed, 41 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h index 5f1339cb5fd..28c73d23d82 100644 --- a/xlators/mgmt/glusterd/src/glusterd-messages.h +++ b/xlators/mgmt/glusterd/src/glusterd-messages.h @@ -2310,6 +2310,14 @@ * @recommendedaction * */ +#define GD_MSG_VOL_NOT_DISPERSE (GLUSTERD_COMP_BASE + 282) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ #define GD_MSG_OLD_REMOVE_BRICK_EXISTS (GLUSTERD_COMP_BASE + 283) /*! diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index b3f6c40d7f0..3229e17fd5f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -720,6 +720,35 @@ out: } static int +validate_disperse (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) +{ + char errstr[2048] = ""; + int ret = -1; + xlator_t *this = NULL; + + this = THIS; + GF_VALIDATE_OR_GOTO ("glusterd", this, out); + + if (volinfo->type != GF_CLUSTER_TYPE_DISPERSE) { + snprintf (errstr, sizeof (errstr), + "Cannot set %s for a non-disperse volume.", key); + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_VOL_NOT_DISPERSE, "%s", errstr); + *op_errstr = gf_strdup (errstr); + ret = -1; + goto out; + } + ret = 0; + +out: + gf_msg_debug (ret == 0 ? THIS->name : "glusterd", 0, "Returning %d", + ret); + + return ret; +} + +static int validate_replica (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value, char **op_errstr) { @@ -3044,7 +3073,8 @@ struct volopt_map_entry glusterd_volopt_map[] = { { .key = "cluster.shd-max-threads", .voltype = "cluster/replicate", .op_version = GD_OP_VERSION_3_7_12, - .flags = OPT_FLAG_CLIENT_OPT + .flags = OPT_FLAG_CLIENT_OPT, + .validate_fn = validate_replica }, { .key = "cluster.shd-wait-qlength", .voltype = "cluster/replicate", @@ -3087,7 +3117,8 @@ struct volopt_map_entry glusterd_volopt_map[] = { { .key = "disperse.shd-max-threads", .voltype = "cluster/disperse", .op_version = GD_OP_VERSION_3_9_0, - .flags = OPT_FLAG_CLIENT_OPT + .flags = OPT_FLAG_CLIENT_OPT, + .validate_fn = validate_disperse }, { .key = "disperse.shd-wait-qlength", .voltype = "cluster/disperse", |