From 58ef6a233f43bc644be55d2b5510b12718a6835e Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Fri, 24 Apr 2015 15:33:25 +0530 Subject: tiering: Send both attach-tier and tier-start together Back port of http://review.gluster.org/10363 After attaching tier, we have to start tier rebalance process. This patch is to trigger tier start along with attch-tier. >Change-Id: I39380f95123f0087a82213ef263f9f33adcc5adc >BUG: 1214222 >Signed-off-by: Mohammed Rafi KC >Reviewed-on: http://review.gluster.org/10363 >Tested-by: Gluster Build System >Reviewed-by: Dan Lambright Change-Id: Ia27e97a9dc0772f3f56b991ce4019281ab7bf1b5 BUG: 1219848 Signed-off-by: Mohammed Rafi KC Reviewed-on: http://review.gluster.org/10711 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: Vijay Bellur --- cli/src/cli-rpc-ops.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 933dbbd3542..a6315e28e43 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -4265,9 +4265,17 @@ int32_t gf_cli_attach_tier (call_frame_t *frame, xlator_t *this, void *data) { - gf_cli_req req = {{0,} }; - int ret = 0; - dict_t *dict = NULL; + gf_cli_req req = {{0,} }; + int ret = 0; + dict_t *dict = NULL; + dict_t *newdict = NULL; + char *tierwords[] = {"volume", "rebalance", "", + "tier", "start", NULL}; + const char **words = (const char **)tierwords; + int wordcount = 5; + char *volname = NULL; + cli_local_t *local = NULL; + cli_local_t *oldlocal = NULL; if (!frame || !this || !data) { ret = -1; @@ -4283,6 +4291,39 @@ gf_cli_attach_tier (call_frame_t *frame, xlator_t *this, (xdrproc_t) xdr_gf_cli_req, dict, GLUSTER_CLI_ATTACH_TIER, this, cli_rpc_prog, NULL); + if (ret) + goto out; + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to get volume name"); + goto notify_cli; + } + + words[2] = volname; + ret = cli_cmd_volume_defrag_parse ((const char **)words, + wordcount, &newdict); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to parse tier start " + "command"); + goto notify_cli; + } + + gf_log ("cli", GF_LOG_DEBUG, "Sending tier start"); + + oldlocal = frame->local; + CLI_LOCAL_INIT (local, words, frame, newdict); + ret = gf_cli_defrag_volume (frame, this, newdict); + frame->local = oldlocal; + cli_local_wipe (local); + +notify_cli: + if (ret) { + cli_out ("Failed to run tier start. Please execute tier start " + "command explictly"); + cli_out ("Usage : gluster volume rebalance tier " + "start"); + } + out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); -- cgit