summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-volume.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-08-09 05:38:46 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-11 22:24:32 -0700
commit0b501ac95edc0ef5945228eb47e6482cfc4efa41 (patch)
tree58fa16eb100868a65e754f704b2a19817250ca91 /cli/src/cli-cmd-volume.c
parent6ff316dca7c9eebab14e71b6ad0908c2e45a5ee2 (diff)
'gluster volume rebalance' related fixes
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1307 (gluster volume defrag <VOLNAME> status) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1307
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r--cli/src/cli-cmd-volume.c54
1 files changed, 41 insertions, 13 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 22844c500ae..63c15473072 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -219,8 +219,7 @@ cli_cmd_volume_rename_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
dict = dict_new ();
-
- if (dict)
+ if (!dict)
goto out;
GF_ASSERT (words[2]);
@@ -254,34 +253,57 @@ out:
return ret;
}
+void
+cli_cmd_volume_defrag_usage ()
+{
+ cli_out ("Usage: volume rebalance <volname> <start|stop|status>");
+}
int
cli_cmd_volume_defrag_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
{
- int ret = -1;
- rpc_clnt_procedure_t *proc = NULL;
- call_frame_t *frame = NULL;
- char *volname = NULL;
-
+ int ret = -1;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
+ dict_t *dict = NULL;
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
goto out;
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ GF_ASSERT (words[2]);
+
+ if (!(words[3])) {
+ cli_cmd_volume_defrag_usage();
+ goto out;
+ }
//TODO: Build validation here
- volname = (char *)words[2];
- GF_ASSERT (volname);
+ ret = dict_set_str (dict, "volname", (char *)words[2]);
+ if (ret)
+ goto out;
+
+ ret = dict_set_str (dict, "command", (char *)words[3]);
+ if (ret)
+ goto out;
proc = &cli_rpc_prog->proctable[GF1_CLI_DEFRAG_VOLUME];
if (proc->fn) {
- ret = proc->fn (frame, THIS, volname);
+ ret = proc->fn (frame, THIS, dict);
}
out:
- if (!proc && ret)
- cli_out ("Defrag of Volume %s failed", volname);
+ if (!proc && ret) {
+ if (dict)
+ dict_destroy (dict);
+
+ cli_out ("Defrag of Volume %s failed", (char *)words[2]);
+ }
return 0;
}
@@ -438,7 +460,13 @@ struct cli_cmd volume_cmds[] = {
{ "volume remove-brick <VOLNAME> [(replica <COUNT>)|(stripe <COUNT>)] <BRICK> ...",
cli_cmd_volume_remove_brick_cbk },
- { "volume defrag <VOLNAME>",
+ { "volume rebalance <VOLNAME> start",
+ cli_cmd_volume_defrag_cbk },
+
+ { "volume rebalance <VOLNAME> stop",
+ cli_cmd_volume_defrag_cbk },
+
+ { "volume rebalance <VOLNAME> status",
cli_cmd_volume_defrag_cbk },
{ "volume replace-brick <VOLNAME> (<BRICK> <NEW-BRICK>)|pause|abort|start|status",