From f63fbca7540a4c9ce090e1ed5941ed8777ff6316 Mon Sep 17 00:00:00 2001 From: Joseph Fernandes Date: Mon, 21 Apr 2014 20:28:22 +0530 Subject: [glusterd/snapshot] snapshot create force option Implement force option in snapshot create i.e 1) Creation of snapshot fails if the original volume bricks are down 2) With a force option creation of snapshot will continue even if the original volume bricks are down. This was the fix for bugs 1089527 and 1083502 Change-Id: I8de0242adf8ee0af00db9fa8701d86fabc12e7fc BUG: 1090042 Signed-off-by: Joseph Fernandes Reviewed-on: http://review.gluster.org/7520 Reviewed-by: Atin Mukherjee Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-parser.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 5fdb9d08a74..de0654a744b 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2986,12 +2986,13 @@ out: */ int cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { - uint64_t i = 0; + uint64_t i = 0; int ret = -1; - uint64_t volcount = 0; - char key[PATH_MAX] = ""; + uint64_t volcount = 0; + char key[PATH_MAX] = ""; char *snapname = NULL; - unsigned int cmdi = 2; + unsigned int cmdi = 2; + int flags = 0; /* cmdi is command index, here cmdi is "2" (gluster snapshot create)*/ GF_ASSERT (words); @@ -3107,18 +3108,15 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { */ } - if ((strcmp (words[i], "force") != 0)) { + if (strcmp (words[i], "force") == 0) { + flags = GF_CLI_FLAG_OP_FORCE; + + } else { ret = -1; cli_err ("Invalid Syntax."); gf_log ("cli", GF_LOG_ERROR, "Invalid Syntax"); goto out; } - ret = dict_set_int8 (dict, "snap-force", 1); - if (ret) { - gf_log ("cli", GF_LOG_ERROR, "Could not save " - "snap force option"); - goto out; - } /* Check if the command has anything after "force" keyword */ if (++i < wordcount) { @@ -3130,6 +3128,15 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount) { ret = 0; out: + if(ret == 0) { + /*Adding force flag in either of the case i.e force set + * or unset*/ + ret = dict_set_int32 (dict, "flags", flags); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Could not save " + "snap force option"); + } + } return ret; } -- cgit