From a8d4c9bf5f36a4ed02b42a6b80bc73e08fc7995c Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Tue, 25 Oct 2016 12:56:05 +0530 Subject: geo-rep/cli: Validate Checkpoint label Checkpoint command accepts "now" or any other Time in "%Y-%m-%d %H:%M:%S" format as label. Validation added with this patch for the input label. Checkpoint set will fail for invalid label. > Reviewed-on: http://review.gluster.org/15721 > Smoke: Gluster Build System > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Saravanakumar Arumugam > Reviewed-by: Kotresh HR BUG: 1395627 Change-Id: I23518c151ab4b294f64cae3b78baaacb3d8f7b82 Signed-off-by: Aravinda VK (cherry picked from commit 8a1993b32f476765f9f5c9294e7c3f2ae75198a0) Reviewed-on: http://review.gluster.org/15855 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Niels de Vos --- cli/src/cli-cmd-parser.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 692bd26e969..e0eb8cff413 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "cli.h" #include "cli-cmd.h" @@ -2366,6 +2367,9 @@ config_parse (const char **words, int wordcount, dict_t *dict, char *append_str = NULL; size_t append_len = 0; char *subop = NULL; + char *ret_chkpt = NULL; + struct tm checkpoint_time; + char chkpt_buf[20] = ""; switch ((wordcount - 1) - cmdi) { case 0: @@ -2427,6 +2431,27 @@ config_parse (const char **words, int wordcount, dict_t *dict, } snprintf (append_str, 300, "%" GF_PRI_SECOND, tv.tv_sec); + } else if ((strcmp (words[cmdi + 1], "checkpoint") == 0) && + (strcmp (append_str, "now") != 0)) { + memset(&checkpoint_time, 0, sizeof(struct tm)); + ret_chkpt = strptime(append_str, "%Y-%m-%d %H:%M:%S", + &checkpoint_time); + + if (ret_chkpt == NULL) { + ret = -1; + cli_err ("Invalid Checkpoint label. Use format " + "\"Y-m-d H:M:S\", Example: 2016-10-25 15:30:45"); + goto out; + } + GF_FREE (append_str); + append_str = GF_CALLOC (1, 300, cli_mt_append_str); + if (!append_str) { + ret = -1; + goto out; + } + strftime (chkpt_buf, sizeof(chkpt_buf), "%s", + &checkpoint_time); + snprintf (append_str, 300, "%s", chkpt_buf); } ret = dict_set_dynstr (dict, "op_value", append_str); -- cgit From e06f4590616dfe7b93e8ac147ed812756df4f22d Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Thu, 22 Sep 2016 16:48:54 +0530 Subject: cluster/afr: CLI for granular entry heal enablement/disablement Backport of: http://review.gluster.org/15747 When there are already existing non-granular indices created that are yet to be healed, if granular-entry-heal option is toggled from 'off' to 'on', AFR self-heal whenever it kicks in, will try to look for granular indices in 'entry-changes'. Because of the absence of name indices, granular entry healing logic will fail to heal these directories, and worse yet unset pending extended attributes with the assumption that are no entries that need heal. To get around this, a new CLI is introduced which will invoke glfsheal program to figure whether at the time an attempt is made to enable granular entry heal, there are pending heals on the volume OR there are one or more bricks that are down. If either of them is true, the command will be failed with the appropriate error. New CLI: gluster volume heal granular-entry-heal {enable,disable} Change-Id: I342e0390f847fcb015a50ef58aedfcbcb58f4ed3 BUG: 1398501 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/15942 NetBSD-regression: NetBSD Build System Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- cli/src/cli-cmd-parser.c | 16 +++++++++++++++- cli/src/cli-cmd-volume.c | 28 +++++++++++++++++----------- cli/src/cli-rpc-ops.c | 8 ++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index e0eb8cff413..8a446595e79 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3611,7 +3611,8 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount, if (wordcount == 5) { if (strcmp (words[3], "info") && - strcmp (words[3], "statistics")) { + strcmp (words[3], "statistics") && + strcmp (words[3], "granular-entry-heal")) { ret = -1; goto out; } @@ -3641,6 +3642,19 @@ cli_cmd_volume_heal_options_parse (const char **words, int wordcount, goto done; } } + + if (!strcmp (words[3], "granular-entry-heal")) { + if (!strcmp (words[4], "enable")) { + ret = dict_set_int32 (dict, "heal-op", + GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE); + goto done; + } else if (!strcmp (words[4], "disable")) { + ret = dict_set_int32 (dict, "heal-op", + GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE); + goto done; + } + } + ret = -1; goto out; } diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index c721171f517..0d25279f381 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -2151,7 +2151,8 @@ cli_print_brick_status (cli_volume_status_t *status) (op == GF_SHD_OP_SBRAIN_HEAL_FROM_LATEST_MTIME) ||\ (op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) || \ (op == GF_SHD_OP_INDEX_SUMMARY) || \ - (op == GF_SHD_OP_SPLIT_BRAIN_FILES)) + (op == GF_SHD_OP_SPLIT_BRAIN_FILES) || \ + (op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE)) int cli_launch_glfs_heal (int heal_op, dict_t *options) @@ -2200,6 +2201,10 @@ cli_launch_glfs_heal (int heal_op, dict_t *options) runner_add_args (&runner, "xml", NULL); } break; + case GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE: + case GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE: + runner_add_args (&runner, "granular-entry-heal-op", NULL); + break; default: ret = -1; } @@ -2211,11 +2216,11 @@ cli_launch_glfs_heal (int heal_op, dict_t *options) printf ("%s", out); } ret = runner_end (&runner); - ret = WEXITSTATUS (ret); out: return ret; } + int cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) @@ -2252,19 +2257,19 @@ cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word, goto out; if (NEEDS_GLFS_HEAL (heal_op)) { ret = cli_launch_glfs_heal (heal_op, options); - if (ret == -1) + if (ret < 0) + goto out; + if (heal_op != GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE) goto out; } - else { - proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME]; - CLI_LOCAL_INIT (local, words, frame, options); + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME]; - if (proc->fn) { - ret = proc->fn (frame, THIS, options); - } - } + CLI_LOCAL_INIT (local, words, frame, options); + if (proc->fn) { + ret = proc->fn (frame, THIS, options); + } out: if (ret) { cli_cmd_sent_status_get (&sent); @@ -2673,7 +2678,8 @@ struct cli_cmd volume_cmds[] = { "statistics [heal-count [replica ]] |" "info [healed | heal-failed | split-brain] |" "split-brain {bigger-file | latest-mtime |" - "source-brick []}]", + "source-brick []} |" + "granular-entry-heal {enable | disable}]", cli_cmd_volume_heal_cbk, "self-heal commands on volume specified by "}, diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index d88ddd7f136..602d3ff1611 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -8670,6 +8670,14 @@ gf_cli_heal_volume_cbk (struct rpc_req *req, struct iovec *iov, operation = ""; heal_op_str = "Disable heal"; break; + case GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE: + operation = ""; + heal_op_str = "Enable granular entry heal"; + break; + case GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE: + operation = ""; + heal_op_str = "Disable granular entry heal"; + break; } if (rsp.op_ret) { -- cgit From 48031e69fd8928e79b3ae4ae49640530e131e2fd Mon Sep 17 00:00:00 2001 From: Rajesh Joseph Date: Tue, 22 Nov 2016 01:48:26 +0530 Subject: cli: glusterfs_ctx_defaults_init should not re-initialize ctx->locks glusterfs_ctx_new already initialize ctx->locks therefore the second initialization in glusterfs_ctx_defaults_init does not make sense. > Reviewed-on: http://review.gluster.org/15904 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Atin Mukherjee (cherry picked from commit 8df8a2308fcf5efda638f160428158127930d00f) Change-Id: I8a44bed13af20e60e8bafb05360e88c0b237056c BUG: 1400802 Signed-off-by: Rajesh Joseph Reviewed-on: http://review.gluster.org/16003 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'cli') diff --git a/cli/src/cli.c b/cli/src/cli.c index 518ae265f22..2ecaae415d6 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -154,8 +154,6 @@ glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx) LOCK_INIT (&pool->lock); ctx->pool = pool; - LOCK_INIT (&ctx->lock); - cmd_args = &ctx->cmd_args; INIT_LIST_HEAD (&cmd_args->xlator_options); -- cgit