summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorhari gowtham <hgowtham@redhat.com>2017-01-23 16:38:00 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-08-01 11:08:04 +0000
commite5db980504bc4ace037ea806ad89a1ca897150d5 (patch)
treeb1e1b7141d2b5467255aea4f3d679b1c09233216 /cli/src
parent3023c4bd7651d4503830c36676cd08864e315cdf (diff)
tier: separation of attach-tier from add-brick
PROBLEM: Both attach tier and add brick have the same RPC and set of code. This becomes a hurdle while tring to implement add brick on a tiered volume. FIX: This patch separates the add brick and attach tier giving them separate RPCs. Change-Id: Iec57e972be968a9ff00b15b507e56a4f6dc398a2 BUG: 1376326 Signed-off-by: hari gowtham <hgowtham@redhat.com> Reviewed-on: https://review.gluster.org/15503 Smoke: Gluster Build System <jenkins@build.gluster.org> Tested-by: hari gowtham <hari.gowtham005@gmail.com> Reviewed-by: Samikshan Bairagya <samikshan@gmail.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-volume.c2
-rw-r--r--cli/src/cli-rpc-ops.c90
2 files changed, 89 insertions, 3 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index a83e281a23c..e6d168d3d8f 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1169,7 +1169,7 @@ do_cli_cmd_volume_attach_tier (struct cli_state *state,
if (ret)
goto out;
- proc = &cli_rpc_prog->proctable[GLUSTER_CLI_ATTACH_TIER];
+ proc = &cli_rpc_prog->proctable[GLUSTER_CLI_ADD_TIER_BRICK];
CLI_LOCAL_INIT (local, words, frame, options);
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index ff44a22be78..ab1519705cf 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2367,6 +2367,58 @@ out:
}
int
+gf_cli_add_tier_brick_cbk (struct rpc_req *req, struct iovec *iov,
+ int count, void *myframe)
+{
+ gf_cli_rsp rsp = {0,};
+ int ret = -1;
+ char msg[1024] = {0,};
+
+ GF_VALIDATE_OR_GOTO ("cli", myframe, out);
+
+ if (-1 == req->rpc_status) {
+ goto out;
+ }
+
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
+ if (ret < 0) {
+ gf_log (((call_frame_t *) myframe)->this->name, GF_LOG_ERROR,
+ "Failed to decode xdr response");
+ goto out;
+ }
+
+
+ gf_log ("cli", GF_LOG_INFO, "Received resp to attach tier");
+
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ snprintf (msg, sizeof (msg), "%s", rsp.op_errstr);
+ else
+ snprintf (msg, sizeof (msg), "Attach tier %s",
+ (rsp.op_ret) ? "unsuccessful" : "successful");
+
+ if (global_state->mode & GLUSTER_MODE_XML) {
+ ret = cli_xml_output_str ("volAttachTier", msg, rsp.op_ret,
+ rsp.op_errno, rsp.op_errstr);
+ if (ret)
+ gf_log ("cli", GF_LOG_ERROR,
+ "Error outputting to xml");
+ goto out;
+ }
+
+ if (rsp.op_ret)
+ cli_err ("volume attach-tier: failed: %s", msg);
+ else
+ cli_out ("volume attach-tier: success");
+ ret = rsp.op_ret;
+
+out:
+ cli_cmd_broadcast_response (ret);
+ free (rsp.dict.dict_val);
+ free (rsp.op_errstr);
+ return ret;
+}
+
+int
gf_cli_attach_tier_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
@@ -2374,7 +2426,7 @@ gf_cli_attach_tier_cbk (struct rpc_req *req, struct iovec *iov,
int ret = -1;
char msg[1024] = {0,};
- GF_ASSERT (myframe);
+ GF_VALIDATE_OR_GOTO ("cli", myframe, out);
if (-1 == req->rpc_status) {
goto out;
@@ -4886,6 +4938,39 @@ out:
}
int32_t
+gf_cli_add_tier_brick (call_frame_t *frame, xlator_t *this,
+ void *data)
+{
+ gf_cli_req req = { {0,} };
+ int ret = 0;
+ dict_t *dict = NULL;
+
+ if (!frame || !this || !data) {
+ ret = -1;
+ goto out;
+ }
+
+ dict = data;
+
+ ret = cli_to_glusterd (&req, frame, gf_cli_add_tier_brick_cbk,
+ (xdrproc_t) xdr_gf_cli_req, dict,
+ GLUSTER_CLI_ADD_TIER_BRICK, this,
+ cli_rpc_prog, NULL);
+ if (ret) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to send request to "
+ "glusterd");
+ goto out;
+ }
+
+out:
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ GF_FREE (req.dict.dict_val);
+ return ret;
+}
+
+
+int32_t
gf_cli_attach_tier (call_frame_t *frame, xlator_t *this,
void *data)
{
@@ -11961,7 +12046,8 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {
[GLUSTER_CLI_TIER] = {"TIER", gf_cli_tier},
[GLUSTER_CLI_GET_STATE] = {"GET_STATE", gf_cli_get_state},
[GLUSTER_CLI_RESET_BRICK] = {"RESET_BRICK", gf_cli_reset_brick},
- [GLUSTER_CLI_REMOVE_TIER_BRICK] = {"DETACH_TIER", gf_cli_remove_tier_brick}
+ [GLUSTER_CLI_REMOVE_TIER_BRICK] = {"DETACH_TIER", gf_cli_remove_tier_brick},
+ [GLUSTER_CLI_ADD_TIER_BRICK] = {"ADD_TIER_BRICK", gf_cli_add_tier_brick}
};
struct rpc_clnt_program cli_prog = {