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>
This commit is contained in:
Gaurav Yadav 2017-01-31 16:14:46 +05:30 committed by Jeff Darcy
parent b7ba77ab3f
commit c618de8069
2 changed files with 41 additions and 2 deletions

View File

@ -2304,6 +2304,14 @@
*/
#define GD_MSG_VOL_NOT_REPLICA (GLUSTERD_COMP_BASE + 281)
/*!
* @messageid
* @diagnosis
* @recommendedaction
*
*/
#define GD_MSG_VOL_NOT_DISPERSE (GLUSTERD_COMP_BASE + 282)
/*!
* @messageid
* @diagnosis

View File

@ -719,6 +719,35 @@ out:
return ret;
}
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",