summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volume-set.c
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2013-02-21 15:35:18 +0530
committerVijay Bellur <vbellur@redhat.com>2013-02-27 21:36:55 -0800
commit4579609e336b423639d844e3cd1d1fa0ff4c62ea (patch)
treef7a41e9a8065c7effb1b99a87895f7b0c03fae5a /xlators/mgmt/glusterd/src/glusterd-volume-set.c
parent202bcaee24477dccf3a2047933a898ec0ad786c2 (diff)
glusterd: Added validation function for stripe-block-size.
Change-Id: I050d01b01eac46550aa435da7d96a972e0393d35 BUG: 770655 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/4561 Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volume-set.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index c183a646098..d3249d3a160 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -94,7 +94,7 @@ out:
return ret;
}
-int
+static int
validate_cache_max_min_size (dict_t *dict, char *key, char *value,
char **op_errstr)
{
@@ -208,6 +208,44 @@ out:
return ret;
}
+static int
+validate_stripe (dict_t *dict, char *key, char *value, char **op_errstr)
+{
+ char errstr[2048] = "";
+ char *volname = NULL;
+ glusterd_conf_t *priv = NULL;
+ glusterd_volinfo_t *volinfo = NULL;
+ int ret = 0;
+ xlator_t *this = NULL;
+
+ this = THIS;
+ GF_ASSERT (this);
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ ret = check_dict_key_value (dict, key, value);
+ if (ret)
+ goto out;
+
+ ret = get_volname_volinfo (dict, &volname, &volinfo);
+ if (ret)
+ goto out;
+
+ if (volinfo->stripe_count == 1) {
+ snprintf (errstr, sizeof (errstr),
+ "Cannot set %s for a non-stripe volume.", key);
+ gf_log (this->name, GF_LOG_ERROR, "%s", errstr);
+ *op_errstr = gf_strdup (errstr);
+ ret = -1;
+ goto out;
+ }
+
+out:
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
/* dispatch table for VOLUME SET
* -----------------------------
*
@@ -417,7 +455,8 @@ struct volopt_map_entry glusterd_volopt_map[] = {
{ .key = "cluster.stripe-block-size",
.voltype = "cluster/stripe",
.option = "block-size",
- .op_version = 1
+ .op_version = 1,
+ .validate_fn = validate_stripe
},
{ .key = "cluster.stripe-coalesce",
.voltype = "cluster/stripe",