summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnuradha Talur <atalur@redhat.com>2013-12-15 13:26:15 +0000
committerVijay Bellur <vbellur@redhat.com>2013-12-19 08:08:51 -0800
commit7b392ad395ae7597a3ed3a1aa7fe61faefd96368 (patch)
tree09d24d8ad3cb15f2e5501684989edd99d6962070
parente22c42d9154c2d9090149003038f38164701dc08 (diff)
glusterd : enable/disable quota using volume set cmd deprecated.
Using the command 'gluster volume set <volname> quota {on|off}' doesn't really enable/disable quota. So, a message to the user is provided. Message asks the user to use 'gluster volume quota <volname> {enable|disable}' instead. Improvement of the previous method to solve the issue. Change-Id: Ibeda35bb49ec7b541d53e592b48fd132380fce76 BUG: 1024626 Signed-off-by: Anuradha Talur <atalur@redhat.com> Reviewed-on: http://review.gluster.org/6512 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c31
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c38
2 files changed, 38 insertions, 31 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 0aeaccd0ce0..dd9398184aa 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -38,13 +38,6 @@ str_getunamb (const char *tok, char **opwords)
return (char *)cli_getunamb (tok, (void **)opwords, id_sel);
}
-static inline gf_boolean_t
-cli_is_quota_cmd (char *key)
-{
- return ((strcmp (key, "quota") == 0) ||
- (strcmp (key, "features.quota") == 0));
-}
-
int32_t
cli_cmd_bricks_parse (const char **words, int wordcount, int brick_index,
char **bricks, int *brick_count)
@@ -865,11 +858,6 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options,
char *value = NULL;
int i = 0;
char str[50] = {0,};
- char *true_keys[] = {"on", "enable", "yes",
- "true", "1", NULL};
- char *false_keys[] = {"off", "disable", "no",
- "false", "0", NULL};
- char *w1 = NULL, *w2 = NULL;
GF_ASSERT (words);
GF_ASSERT (options);
@@ -922,25 +910,6 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options,
if (ret == 0)
*options = dict;
goto out;
- } else if (wordcount == 5 && cli_is_quota_cmd ((char *)words[3])) {
- value = (char *)words[4];
- w1 = str_getunamb (value, true_keys);
- w2 = str_getunamb (value, false_keys);
- if (w1 != NULL) {
- gf_asprintf (op_errstr,"'gluster volume set <VOLNAME> "
- "%s %s' is deprecated. Use 'gluster "
- "volume quota <VOLNAME> enable' instead.",
- (char *)words[3], w1);
- ret = -1;
- goto out;
- } else if (w2 != NULL) {
- gf_asprintf (op_errstr,"'gluster volume set <VOLNAME> "
- "%s %s' is deprecated. Use 'gluster "
- "volume quota <VOLNAME> disable' instead.",
- (char *)words[3], w2);
- ret = -1;
- goto out;
- }
}
for (i = 3; i < wordcount; i+=2) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 0bf7a335298..06ee849f53d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -155,6 +155,40 @@ glusterd_op_sm_inject_all_acc ()
return ret;
}
+static int
+glusterd_check_quota_cmd (char *key, char *value, char *errstr, size_t size)
+{
+ int ret = -1;
+ gf_boolean_t b = _gf_false;
+
+ if ((strcmp (key, "quota") == 0) ||
+ (strcmp (key, "features.quota") == 0)) {
+ ret = gf_string2boolean (value, &b);
+ if (ret)
+ goto out;
+ if (b) {
+ snprintf (errstr, size," 'gluster "
+ "volume set <VOLNAME> %s %s' is "
+ "deprecated. Use 'gluster volume "
+ "quota <VOLNAME> enable' instead.",
+ key, value);
+ ret = -1;
+ goto out;
+ } else {
+ snprintf (errstr, size, " 'gluster "
+ "volume set <VOLNAME> %s %s' is "
+ "deprecated. Use 'gluster volume "
+ "quota <VOLNAME> disable' instead.",
+ key, value);
+ ret = -1;
+ goto out;
+ }
+ }
+ ret = 0;
+out:
+ return ret;
+}
+
int
glusterd_brick_op_build_payload (glusterd_op_t op, glusterd_brickinfo_t *brickinfo,
gd1_mgmt_brick_op_req **req, dict_t *dict)
@@ -544,6 +578,10 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
}
}
+ ret = glusterd_check_quota_cmd (key, value, errstr, sizeof (errstr));
+ if (ret)
+ goto out;
+
if (is_key_glusterd_hooks_friendly (key))
continue;