summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-11-02 18:38:50 +0530
committerVijay Bellur <vijay@gluster.com>2011-11-16 01:42:29 -0800
commit7a97478dd1a343fcc5d9d4eab963882191a3de69 (patch)
tree54f48eacb357561a9ebc5f5089e666e0979c7d55 /xlators/mgmt/glusterd/src/glusterd-brick-ops.c
parent913b21621e2dad9146366f24048ff07a8046e5c5 (diff)
XDR: cli-glusterd xdr consolidation
By using only 1 xdr struct for request and 1 xdr struct for response, we will be able scale better and also be able to parse the o/p better For request use- gf1_cli_req - contains dict For response use- gf1_cli_rsp - conains op_ret, op_errno, op_errstr, dict Change-Id: I94b034e1d8fa82dfd0cf96e7602d4039bc43fef3 BUG: 3720 Reviewed-on: http://review.gluster.com/662 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amar@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-brick-ops.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 76bbe6c9f19..6385ac6786f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -297,7 +297,7 @@ int
glusterd_handle_add_brick (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_add_brick_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
char *brick = NULL;
@@ -309,7 +309,7 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
char *brick_list = NULL;
void *cli_rsp = NULL;
char err_str[2048] = {0,};
- gf1_cli_add_brick_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
glusterd_volinfo_t *volinfo = NULL;
xlator_t *this = NULL;
char *free_ptr = NULL;
@@ -329,23 +329,21 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
INIT_LIST_HEAD (&tmpvolinfo.bricks);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_add_brick_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
snprintf (err_str, sizeof (err_str), "Garbage args received");
goto out;
}
- gf_cmd_log ("Volume add-brick", "on volname: %s attempted",
- cli_req.volname);
gf_log ("glusterd", GF_LOG_INFO, "Received add brick req");
- if (cli_req.bricks.bricks_len) {
+ if (cli_req.dict.dict_len) {
/* Unserialize the dictionary */
dict = dict_new ();
- ret = dict_unserialize (cli_req.bricks.bricks_val,
- cli_req.bricks.bricks_len,
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len,
&dict);
if (ret < 0) {
gf_log ("glusterd", GF_LOG_ERROR,
@@ -354,13 +352,13 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
snprintf (err_str, sizeof (err_str), "Unable to decode "
"the buffer");
goto out;
- } else {
- dict->extra_stdfree = cli_req.bricks.bricks_val;
}
}
ret = dict_get_str (dict, "volname", &volname);
+ gf_cmd_log ("Volume add-brick", "on volname: %s attempted",
+ volname);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
snprintf (err_str, sizeof (err_str), "Unable to get volume "
@@ -562,13 +560,12 @@ out:
dict_unref (dict);
rsp.op_ret = -1;
rsp.op_errno = 0;
- rsp.volname = "";
if (err_str[0] == '\0')
snprintf (err_str, sizeof (err_str), "Operation failed");
rsp.op_errstr = err_str;
cli_rsp = &rsp;
glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf1_cli_add_brick_rsp);
+ (xdrproc_t)xdr_gf_cli_rsp);
ret = 0; //sent error to cli, prevent second reply
}
@@ -580,8 +577,8 @@ out:
glusterd_volume_brickinfos_delete (&tmpvolinfo);
if (brickinfo)
glusterd_brickinfo_delete (brickinfo);
- if (cli_req.volname)
- free (cli_req.volname); //its malloced by xdr
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val); //its malloced by xdr
return ret;
}
@@ -591,7 +588,7 @@ int
glusterd_handle_remove_brick (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_remove_brick_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
int32_t count = 0;
char *brick = NULL;
@@ -606,7 +603,7 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
int32_t sub_volume_end = 0;
glusterd_brickinfo_t *tmp = NULL;
char err_str[2048] = {0};
- gf1_cli_remove_brick_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
void *cli_rsp = NULL;
char vol_type[256] = {0,};
int32_t replica_count = 0;
@@ -614,46 +611,52 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
int32_t tmp_brick_idx = 0;
int found = 0;
int diff_count = 0;
+ char *volname = 0;
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_remove_brick_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_cmd_log ("Volume remove-brick","on volname: %s attempted",cli_req.volname);
+
gf_log ("glusterd", GF_LOG_INFO, "Received rem brick req");
- if (cli_req.bricks.bricks_len) {
+ if (cli_req.dict.dict_len) {
/* Unserialize the dictionary */
dict = dict_new ();
- ret = dict_unserialize (cli_req.bricks.bricks_val,
- cli_req.bricks.bricks_len,
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len,
&dict);
if (ret < 0) {
gf_log ("glusterd", GF_LOG_ERROR,
"failed to "
"unserialize req-buffer to dictionary");
goto out;
- } else {
- dict->extra_stdfree = cli_req.bricks.bricks_val;
}
}
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Unable to get volname");
+ goto out;
+ }
+
+ gf_cmd_log ("Volume remove-brick","on volname: %s attempted", volname);
ret = dict_get_int32 (dict, "count", &count);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get count");
goto out;
}
- ret = glusterd_volinfo_find (cli_req.volname, &volinfo);
+ ret = glusterd_volinfo_find (volname, &volinfo);
if (ret) {
snprintf (err_str, 2048, "Volume %s does not exist",
- cli_req.volname);
+ volname);
gf_log ("", GF_LOG_ERROR, "%s", err_str);
goto out;
}
@@ -739,7 +742,7 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
GF_PATH_COMPLETE);
if (ret) {
snprintf(err_str, 2048,"Incorrect brick %s for volume"
- " %s", brick, cli_req.volname);
+ " %s", brick, volname);
gf_log ("", GF_LOG_ERROR, "%s", err_str);
goto out;
}
@@ -821,10 +824,10 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
}
}
gf_cmd_log ("Volume remove-brick","volname: %s count:%d bricks:%s",
- cli_req.volname, count, brick_list);
+ volname, count, brick_list);
ret = glusterd_op_begin (req, GD_OP_REMOVE_BRICK, dict);
- gf_cmd_log ("Volume remove-brick","on volname: %s %s",cli_req.volname,
+ gf_cmd_log ("Volume remove-brick","on volname: %s %s", volname,
(ret) ? "FAILED" : "SUCCESS");
out:
@@ -833,22 +836,21 @@ out:
dict_unref (dict);
rsp.op_ret = -1;
rsp.op_errno = 0;
- rsp.volname = "";
if (err_str[0] == '\0')
snprintf (err_str, sizeof (err_str), "Operation failed");
gf_log ("", GF_LOG_ERROR, "%s", err_str);
rsp.op_errstr = err_str;
cli_rsp = &rsp;
glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf1_cli_remove_brick_rsp);
+ (xdrproc_t)xdr_gf_cli_rsp);
ret = 0; //sent error to cli, prevent second reply
}
if (brick_list)
GF_FREE (brick_list);
- if (cli_req.volname)
- free (cli_req.volname); //its malloced by xdr
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val); //its malloced by xdr
glusterd_friend_sm ();
glusterd_op_sm ();