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 +++++++++++++++++++++++--------- cli/src/cli.h | 1 + cli/src/cli3_1-cops.c | 6 +++--- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 8b240401297..1421157c89a 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 "}, diff --git a/cli/src/cli.h b/cli/src/cli.h index d6e1a35d6e3..22159025e5e 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -110,6 +110,7 @@ struct cli_local { struct { char *volname; + int flags; } stop_vol; struct { diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c index 77fb3852ba5..728c79095b8 100644 --- a/cli/src/cli3_1-cops.c +++ b/cli/src/cli3_1-cops.c @@ -1095,12 +1095,12 @@ gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t *this, goto out; } - req.volname = data; - + req = *((gf1_cli_stop_vol_req*)data); local = cli_local_get (); if (local) { - local->u.stop_vol.volname = data; + local->u.stop_vol.volname = req.volname; + local->u.stop_vol.flags = req.flags; frame->local = local; } -- cgit