From 0b501ac95edc0ef5945228eb47e6482cfc4efa41 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Mon, 9 Aug 2010 05:38:46 +0000 Subject: 'gluster volume rebalance' related fixes Signed-off-by: Amar Tumballi Signed-off-by: Anand V. Avati BUG: 1307 (gluster volume defrag status) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1307 --- cli/src/cli-cmd-volume.c | 54 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 13 deletions(-) (limited to 'cli/src/cli-cmd-volume.c') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 22844c500..63c154730 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 "); +} 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 [(replica )|(stripe )] ...", cli_cmd_volume_remove_brick_cbk }, - { "volume defrag ", + { "volume rebalance start", + cli_cmd_volume_defrag_cbk }, + + { "volume rebalance stop", + cli_cmd_volume_defrag_cbk }, + + { "volume rebalance status", cli_cmd_volume_defrag_cbk }, { "volume replace-brick ( )|pause|abort|start|status", -- cgit