diff options
-rw-r--r-- | cli/src/cli-cmd-volume.c | 13 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 25 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 19 |
3 files changed, 22 insertions, 35 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index f7586c44c11..f523579a6b2 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -125,6 +125,11 @@ cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word, int parse_error = 0; dict_t *dict = NULL; cli_local_t *local = NULL; + gf_answer_t answer = GF_ANSWER_NO; + const char *question = "Sync volume may make data " + "inaccessible while the sync " + "is in progress. Do you want " + "to continue?"; if ((wordcount < 3) || (wordcount > 4)) { cli_usage_out (word->pattern); @@ -159,6 +164,14 @@ cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word, goto out; } + if (!(state->mode & GLUSTER_MODE_SCRIPT)) { + answer = cli_cmd_get_confirmation (state, question); + if (GF_ANSWER_NO == answer) { + ret = 0; + goto out; + } + } + proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SYNC_VOLUME]; frame = create_frame (THIS, THIS->ctx->pool); diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index f33d2caeb56..592fbbdb260 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -1137,7 +1137,6 @@ glusterd_handle_sync_volume (rpcsvc_request_t *req) dict_t *dict = NULL; gf_cli_rsp cli_rsp = {0.}; char msg[2048] = {0,}; - glusterd_volinfo_t *volinfo = NULL; char *volname = NULL; gf1_cli_sync_volume flags = 0; char *hostname = NULL; @@ -1194,30 +1193,6 @@ glusterd_handle_sync_volume (rpcsvc_request_t *req) goto out; } - if (!flags) { - ret = glusterd_volinfo_find (volname, &volinfo); - if (!ret) { - snprintf (msg, sizeof (msg), "please delete the " - "volume: %s before sync", volname); - ret = -1; - goto out; - } - - ret = dict_set_dynmstr (dict, "volname", volname); - if (ret) { - gf_log ("", GF_LOG_ERROR, "volume name set failed"); - snprintf (msg, sizeof (msg), "volume name set failed"); - goto out; - } - } else { - if (glusterd_volume_count_get ()) { - snprintf (msg, sizeof (msg), "please delete all the " - "volumes before full sync"); - ret = -1; - goto out; - } - } - ret = glusterd_op_begin (req, GD_OP_SYNC_VOLUME, dict); out: diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index d5686bbab28..4ca70516163 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -785,9 +785,6 @@ glusterd_op_stage_sync_volume (dict_t *dict, char **op_errstr) if (ret) goto out; - ret = glusterd_validate_volume_id (dict, volinfo); - if (ret) - goto out; } else { ret = 0; } @@ -2240,6 +2237,7 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) { int ret = -1; void *ctx = NULL; + dict_t *dict = NULL; dict_t *req_dict = NULL; glusterd_op_t op = GD_OP_NONE; char *volname = NULL; @@ -2271,10 +2269,10 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) } #undef GD_SYNC_OPCODE_KEY + dict = ctx; switch (op) { case GD_OP_CREATE_VOLUME: { - dict_t *dict = ctx; ++glusterfs_port; ret = dict_set_int32 (dict, "port", glusterfs_port); @@ -2286,7 +2284,6 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) case GD_OP_GSYNC_SET: { - dict_t *dict = ctx; ret = glusterd_op_gsync_args_get (dict, &errstr, &volname, @@ -2303,7 +2300,6 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) case GD_OP_SET_VOLUME: { - dict_t *dict = ctx; ret = dict_get_str (dict, "volname", &volname); if (ret) { gf_log (THIS->name, GF_LOG_CRITICAL, @@ -2323,9 +2319,14 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) } break; + case GD_OP_SYNC_VOLUME: + { + dict_copy (dict, req_dict); + break; + } + case GD_OP_STATUS_VOLUME: { - dict_t *dict = ctx; ret = dict_get_uint32 (dict, "cmd", &status_cmd); if (ret) { @@ -2339,7 +2340,7 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) break; } } - + /*fall-through*/ case GD_OP_DELETE_VOLUME: case GD_OP_START_VOLUME: case GD_OP_STOP_VOLUME: @@ -2348,7 +2349,6 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) case GD_OP_RESET_VOLUME: case GD_OP_REMOVE_BRICK: case GD_OP_LOG_ROTATE: - case GD_OP_SYNC_VOLUME: case GD_OP_QUOTA: case GD_OP_PROFILE_VOLUME: case GD_OP_REBALANCE: @@ -2357,7 +2357,6 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) case GD_OP_CLEARLOCKS_VOLUME: case GD_OP_DEFRAG_BRICK_VOLUME: { - dict_t *dict = ctx; ret = dict_get_str (dict, "volname", &volname); if (ret) { gf_log (THIS->name, GF_LOG_CRITICAL, |