From 157560b6dce9cf790e8405ce895d80f4efab1539 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sat, 28 Aug 2010 06:02:54 +0000 Subject: cli, mgmt/glusterd: added volume stop force functionality Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1361 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1361 --- cli/src/cli-cmd-volume.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 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 8b2404012..1421157c8 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -31,6 +31,7 @@ #include "cli.h" #include "cli-cmd.h" #include "cli-mem-types.h" +#include "cli1-xdr.h" extern struct rpc_clnt *global_rpc; @@ -49,7 +50,7 @@ cli_cmd_volume_start_usage () void cli_cmd_volume_stop_usage () { - cli_out ("Usage: volume stop "); + cli_out ("Usage: volume stop [force]"); } void @@ -212,29 +213,42 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word, int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; - char *volname = NULL; - + int flags = 0; + gf1_cli_stop_vol_req req = {0,}; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; - if (wordcount != 3) { + if (wordcount < 3 || wordcount > 4) { cli_cmd_volume_stop_usage (); goto out; } - volname = (char *)words[2]; + req.volname = (char *)words[2]; + if (!req.volname) + goto out; + if (wordcount == 4) { + if (!strcmp("force", words[3])) { + flags |= GF_CLI_FLAG_OP_FORCE; + } else { + ret = -1; + cli_cmd_volume_stop_usage (); + goto out; + } + } + + req.flags = flags; proc = &cli_rpc_prog->proctable[GF1_CLI_STOP_VOLUME]; if (proc->fn) { - ret = proc->fn (frame, THIS, volname); + ret = proc->fn (frame, THIS, &req); } out: - if (!proc && ret && volname) - cli_out ("Stopping Volume %s failed", volname); + if (!proc && ret && req.volname) + cli_out ("Stopping Volume %s failed", req.volname); return ret; } @@ -519,7 +533,7 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_start_cbk, "start volume specified by "}, - { "volume stop ", + { "volume stop [force]", cli_cmd_volume_stop_cbk, "stop volume specified by "}, -- cgit