summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--cli/src/cli-cmd-parser.c2
-rw-r--r--cli/src/cli-cmd-volume.c114
-rw-r--r--cli/src/cli-rpc-ops.c965
-rw-r--r--cli/src/cli.h44
-rw-r--r--rpc/xdr/src/cli1-xdr.c731
-rw-r--r--rpc/xdr/src/cli1-xdr.h498
-rw-r--r--rpc/xdr/src/cli1-xdr.x303
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c66
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c228
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-log-ops.c127
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c195
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c27
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rpc-ops.c443
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c270
16 files changed, 1443 insertions, 2580 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index eaeb3f1aeea..d363e934a57 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1857,7 +1857,7 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount,
if (ret)
goto out;
- ret = dict_set_int32 (dict, "option-cnt", option_cnt);
+ ret = dict_set_int32 (dict, "option_cnt", option_cnt);
if (ret)
goto out;
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 36e4c659c87..8d3ff557ab7 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -88,9 +88,9 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct cli_cmd_word *word,
if (!local)
goto out;
- local->u.get_vol.flags = ctx.flags;
+ local->get_vol.flags = ctx.flags;
if (ctx.volname)
- local->u.get_vol.volname = gf_strdup (ctx.volname);
+ local->get_vol.volname = gf_strdup (ctx.volname);
frame->local = local;
@@ -116,9 +116,9 @@ cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word,
int ret = -1;
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
- gf1_cli_sync_volume_req req = {0,};
int sent = 0;
int parse_error = 0;
+ dict_t *dict = NULL;
if ((wordcount < 3) || (wordcount > 4)) {
cli_usage_out (word->pattern);
@@ -126,14 +126,32 @@ cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
if ((wordcount == 3) || !strcmp(words[3], "all")) {
- req.flags = GF_CLI_SYNC_ALL;
- req.volname = "";
+ ret = dict_set_int32 (dict, "flags", (int32_t)
+ GF_CLI_SYNC_ALL);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to set"
+ "flag");
+ goto out;
+ }
} else {
- req.volname = (char *)words[3];
+ ret = dict_set_str (dict, "volname", (char *) words[3]);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to set "
+ "volume");
+ goto out;
+ }
}
- req.hostname = (char *)words[2];
+ ret = dict_set_str (dict, "hostname", (char *) words[2]);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to set hostname");
+ goto out;
+ }
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SYNC_VOLUME];
@@ -142,7 +160,7 @@ cli_cmd_sync_volume_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
if (proc->fn) {
- ret = proc->fn (frame, THIS, &req);
+ ret = proc->fn (frame, THIS, dict);
}
out:
@@ -152,6 +170,8 @@ out:
cli_out ("Volume sync failed");
}
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -439,9 +459,10 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
int ret = -1;
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
- gf1_cli_start_vol_req req = {0,};
int sent = 0;
int parse_error = 0;
+ dict_t *dict = NULL;
+ int flags = 0;
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
@@ -453,13 +474,23 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
- req.volname = (char *)words[2];
- if (!req.volname)
+ dict = dict_new ();
+ if (!dict) {
+ goto out;
+ }
+
+ if (!words[2])
+ goto out;
+
+ ret = dict_set_str (dict, "volname", (char *)words[2]);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "dict set failed");
goto out;
+ }
if (wordcount == 4) {
if (!strcmp("force", words[3])) {
- req.flags |= GF_CLI_FLAG_OP_FORCE;
+ flags |= GF_CLI_FLAG_OP_FORCE;
} else {
ret = -1;
cli_usage_out (word->pattern);
@@ -467,14 +498,28 @@ cli_cmd_volume_start_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
}
+ ret = dict_set_int32 (dict, "flags", flags);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "dict set failed");
+ goto out;
+ }
+
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to serialize dict");
+ goto out;
+ }
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_START_VOLUME];
if (proc->fn) {
- ret = proc->fn (frame, THIS, &req);
+ ret = proc->fn (frame, THIS, dict);
}
out:
+ if (dict)
+ dict_unref (dict);
if (ret) {
cli_cmd_sent_status_get (&sent);
if ((sent == 0) && (parse_error == 0))
@@ -534,10 +579,11 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
int flags = 0;
- gf1_cli_stop_vol_req req = {0,};
gf_answer_t answer = GF_ANSWER_NO;
int sent = 0;
int parse_error = 0;
+ dict_t *dict = NULL;
+ char *volname = NULL;
const char *question = "Stopping volume will make its data inaccessible. "
"Do you want to continue?";
@@ -552,9 +598,14 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
- req.volname = (char *)words[2];
- if (!req.volname)
+ volname = (char*) words[2];
+
+ dict = dict_new ();
+ ret = dict_set_str (dict, "volname", volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "dict set failed");
goto out;
+ }
if (wordcount == 4) {
if (!strcmp("force", words[3])) {
@@ -566,6 +617,12 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
}
+ ret = dict_set_int32 (dict, "flags", flags);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "dict set failed");
+ goto out;
+ }
answer = cli_cmd_get_confirmation (state, question);
@@ -574,20 +631,20 @@ cli_cmd_volume_stop_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
- req.flags = flags;
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STOP_VOLUME];
if (proc->fn) {
- ret = proc->fn (frame, THIS, &req);
+ ret = proc->fn (frame, THIS, dict);
}
out:
if (ret) {
cli_cmd_sent_status_get (&sent);
if ((sent == 0) && (parse_error == 0))
- cli_out ("Volume stop on '%s' failed", req.volname);
+ cli_out ("Volume stop on '%s' failed", volname);
}
-
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -1476,9 +1533,9 @@ cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word,
int ret = -1;
rpc_clnt_procedure_t *proc = NULL;
call_frame_t *frame = NULL;
- gf1_cli_heal_vol_req req = {0,};
int sent = 0;
int parse_error = 0;
+ dict_t *dict = NULL;
frame = create_frame (THIS, THIS->ctx->pool);
if (!frame)
@@ -1490,14 +1547,20 @@ cli_cmd_volume_heal_cbk (struct cli_state *state, struct cli_cmd_word *word,
goto out;
}
- req.volname = (char *)words[2];
- if (!req.volname)
+ dict = dict_new ();
+ if (!dict)
+ goto out;
+
+ ret = dict_set_str (dict, "volname", (char *) words[2]);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to set volname");
goto out;
+ }
proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME];
if (proc->fn) {
- ret = proc->fn (frame, THIS, &req);
+ ret = proc->fn (frame, THIS, dict);
}
out:
@@ -1507,6 +1570,9 @@ out:
cli_out ("Volume heal failed");
}
+ if (dict)
+ dict_unref (dict);
+
return ret;
}
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 55566d8c574..bcaf0cef593 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -385,7 +385,7 @@ int
gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_get_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
dict_t *dict = NULL;
char *volname = NULL;
@@ -414,7 +414,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_get_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
//rsp.op_ret = -1;
@@ -428,7 +428,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
if (!rsp.op_ret) {
- if (!rsp.volumes.volumes_len) {
+ if (!rsp.dict.dict_len) {
cli_out ("No volumes present");
ret = 0;
goto out;
@@ -441,8 +441,8 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = dict_unserialize (rsp.volumes.volumes_val,
- rsp.volumes.volumes_len,
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
&dict);
if (ret) {
@@ -460,16 +460,16 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
local = ((call_frame_t *)myframe)->local;
//cli_out ("Number of Volumes: %d", count);
- if (!count && (local->u.get_vol.flags ==
+ if (!count && (local->get_vol.flags ==
GF_CLI_GET_NEXT_VOLUME)) {
- local->u.get_vol.volname = NULL;
+ local->get_vol.volname = NULL;
ret = 0;
goto out;
- } else if (!count && (local->u.get_vol.flags ==
+ } else if (!count && (local->get_vol.flags ==
GF_CLI_GET_VOLUME)) {
snprintf (err_str, sizeof (err_str),
"Volume %s does not exist",
- local->u.get_vol.volname);
+ local->get_vol.volname);
ret = -1;
goto out;
}
@@ -551,8 +551,8 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,
j = 1;
- GF_FREE (local->u.get_vol.volname);
- local->u.get_vol.volname = gf_strdup (volname);
+ GF_FREE (local->get_vol.volname);
+ local->get_vol.volname = gf_strdup (volname);
if (brick_count)
cli_out ("Bricks:");
@@ -629,7 +629,7 @@ int
gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_create_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
cli_local_t *local = NULL;
char *volname = NULL;
@@ -642,13 +642,13 @@ gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov,
local = ((call_frame_t *) (myframe))->local;
((call_frame_t *) (myframe))->local = NULL;
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_create_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
}
- dict = local->u.create_vol.dict;
+ dict = local->dict;
ret = dict_get_str (dict, "volname", &volname);
@@ -668,8 +668,8 @@ out:
dict_unref (dict);
if (local)
cli_local_wipe (local);
- if (rsp.volname)
- free (rsp.volname);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
if (rsp.op_errstr)
free (rsp.op_errstr);
return ret;
@@ -679,17 +679,18 @@ int
gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_delete_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
cli_local_t *local = NULL;
char *volname = NULL;
call_frame_t *frame = NULL;
+ dict_t *dict = NULL;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_delete_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -700,8 +701,13 @@ gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov,
frame->local = NULL;
if (local)
- volname = local->u.delete_vol.volname;
-
+ dict = local->dict;
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "dict get failed");
+ goto out;
+ }
gf_log ("cli", GF_LOG_INFO, "Received resp to delete volume");
@@ -715,8 +721,11 @@ gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov,
out:
cli_cmd_broadcast_response (ret);
cli_local_wipe (local);
- if (rsp.volname)
- free (rsp.volname);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
+ if (dict)
+ dict_unref (dict);
+
gf_log ("", GF_LOG_INFO, "Returning with %d", ret);
return ret;
}
@@ -725,17 +734,18 @@ int
gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_start_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
cli_local_t *local = NULL;
char *volname = NULL;
call_frame_t *frame = NULL;
+ dict_t *dict = NULL;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_start_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -749,7 +759,13 @@ gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
if (local)
- volname = local->u.start_vol.volname;
+ dict = local->dict;
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "dict get failed");
+ goto out;
+ }
gf_log ("cli", GF_LOG_INFO, "Received resp to start volume");
@@ -765,10 +781,12 @@ out:
cli_cmd_broadcast_response (ret);
if (local)
cli_local_wipe (local);
- if (rsp.volname)
- free (rsp.volname);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
if (rsp.op_errstr)
free (rsp.op_errstr);
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -776,17 +794,18 @@ int
gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_stop_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
cli_local_t *local = NULL;
char *volname = NULL;
call_frame_t *frame = NULL;
+ dict_t *dict = NULL;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_stop_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -797,8 +816,15 @@ gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov,
if (frame)
local = frame->local;
- if (local)
- volname = local->u.start_vol.volname;
+ if (local) {
+ dict = local->dict;
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Unable to get volname from dict");
+ goto out;
+ }
+ }
gf_log ("cli", GF_LOG_INFO, "Received resp to stop volume");
@@ -813,8 +839,10 @@ out:
cli_cmd_broadcast_response (ret);
if (rsp.op_errstr)
free (rsp.op_errstr);
- if (rsp.volname)
- free (rsp.volname);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
+ if (local)
+ cli_local_wipe (local);
return ret;
}
@@ -822,20 +850,25 @@ int
gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf2_cli_defrag_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
cli_local_t *local = NULL;
char *volname = NULL;
call_frame_t *frame = NULL;
char *status = "unknown";
int cmd = 0;
int ret = 0;
+ dict_t *dict = NULL;
+ dict_t *local_dict = NULL;
+ uint64_t files = 0;
+ uint64_t size = 0;
+ uint64_t lookup = 0;
if (-1 == req->rpc_status) {
goto out;
}
ret = xdr_to_generic (*iov, &rsp,
- (xdrproc_t)xdr_gf2_cli_defrag_vol_rsp);
+ (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -847,10 +880,53 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
local = frame->local;
if (local) {
- volname = local->u.defrag_vol.volname;
- cmd = local->u.defrag_vol.cmd;
+ local_dict = local->dict;
+ }
+
+ ret = dict_get_str (local_dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to get volname");
+ goto out;
}
+ ret = dict_get_int32 (local_dict, "rebalance-command", (int32_t*)&cmd);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to get command");
+ goto out;
+ }
+
+ if (rsp.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
+
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
+
+ ret = dict_get_uint64 (dict, "files", &files);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get file count");
+
+ ret = dict_get_uint64 (dict, "size", &size);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get size of xfer");
+
+ ret = dict_get_uint64 (dict, "lookups", &lookup);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get lookedup file count");
+
if (cmd == GF_DEFRAG_CMD_STOP) {
if (rsp.op_ret == -1) {
if (strcmp (rsp.op_errstr, ""))
@@ -861,7 +937,7 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
} else {
cli_out ("stopped rebalance process of volume %s \n"
"(after rebalancing %"PRId64" files totaling "
- "%"PRId64" bytes)", volname, rsp.files, rsp.size);
+ "%"PRId64" bytes)", volname, files, size);
}
goto done;
}
@@ -904,21 +980,21 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
status = "paused";
break;
}
- if (rsp.files && (rsp.op_errno == 1)) {
+ if (files && (rsp.op_errno == 1)) {
cli_out ("rebalance %s: fixed layout %"PRId64,
- status, rsp.files);
+ status, files);
goto done;
}
- if (rsp.files && (rsp.op_errno == 6)) {
+ if (files && (rsp.op_errno == 6)) {
cli_out ("rebalance %s: fixed layout %"PRId64,
- status, rsp.files);
+ status, files);
goto done;
}
- if (rsp.files) {
+ if (files) {
cli_out ("rebalance %s: rebalanced %"PRId64
" files of size %"PRId64" (total files"
" scanned %"PRId64")", status,
- rsp.files, rsp.size, rsp.lookedup_files);
+ files, size, lookup);
goto done;
}
@@ -935,16 +1011,19 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
"successful");
done:
- if (volname)
- GF_FREE (volname);
-
ret = rsp.op_ret;
out:
if (rsp.op_errstr)
free (rsp.op_errstr); //malloced by xdr
- if (rsp.volname)
- free (rsp.volname); //malloced by xdr
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val); //malloced by xdr
+ if (dict)
+ dict_unref (dict);
+ if (local_dict)
+ dict_unref (local_dict);
+ if (local)
+ cli_local_wipe (local);
cli_cmd_broadcast_response (ret);
return ret;
}
@@ -953,14 +1032,14 @@ int
gf_cli3_1_rename_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_rename_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_rename_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -982,14 +1061,14 @@ int
gf_cli3_1_reset_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_reset_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_reset_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1014,7 +1093,7 @@ int
gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_set_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
dict_t *dict = NULL;
char *help_str = NULL;
@@ -1023,7 +1102,7 @@ gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_set_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1063,14 +1142,14 @@ int
gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_add_brick_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_add_brick_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1088,8 +1167,8 @@ gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov,
out:
cli_cmd_broadcast_response (ret);
- if (rsp.volname)
- free (rsp.volname);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
if (rsp.op_errstr)
free (rsp.op_errstr);
return ret;
@@ -1099,16 +1178,19 @@ int
gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf2_cli_defrag_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
char *status = "unknown";
int ret = 0;
+ uint64_t files = 0;
+ uint64_t size = 0;
+ dict_t *dict = NULL;
if (-1 == req->rpc_status) {
goto out;
}
ret = xdr_to_generic (*iov, &rsp,
- (xdrproc_t)xdr_gf2_cli_defrag_vol_rsp);
+ (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1148,30 +1230,55 @@ gf_cli3_remove_brick_status_cbk (struct rpc_req *req, struct iovec *iov,
break;
}
- if (rsp.files && (rsp.op_errno == 1)) {
+ if (rsp.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
+
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
+
+ ret = dict_get_uint64 (dict, "files", &files);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get file count");
+
+ ret = dict_get_uint64 (dict, "size", &size);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get size of xfer");
+
+ if (files && (rsp.op_errno == 1)) {
cli_out ("remove-brick %s: fixed layout %"PRId64,
- status, rsp.files);
+ status,files);
goto out;
}
- if (rsp.files && (rsp.op_errno == 6)) {
+ if (files && (rsp.op_errno == 6)) {
cli_out ("remove-brick %s: fixed layout %"PRId64,
- status, rsp.files);
+ status, files);
goto out;
}
- if (rsp.files) {
+ if (files) {
cli_out ("remove-brick %s: decommissioned %"PRId64
" files of size %"PRId64, status,
- rsp.files, rsp.size);
+ files, size);
goto out;
}
cli_out ("remove-brick %s", status);
out:
- if (rsp.op_errstr)
- free (rsp.op_errstr); //malloced by xdr
- if (rsp.volname)
- free (rsp.volname); //malloced by xdr
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val); //malloced by xdr
+ if (dict)
+ dict_unref (dict);
cli_cmd_broadcast_response (ret);
return ret;
}
@@ -1181,14 +1288,14 @@ int
gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_remove_brick_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_remove_brick_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1206,8 +1313,8 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
out:
cli_cmd_broadcast_response (ret);
- if (rsp.volname)
- free (rsp.volname);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
if (rsp.op_errstr)
free (rsp.op_errstr);
return ret;
@@ -1219,7 +1326,7 @@ int
gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_replace_brick_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
cli_local_t *local = NULL;
call_frame_t *frame = NULL;
@@ -1229,6 +1336,7 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
char *status_reply = NULL;
gf1_cli_replace_op replace_op = 0;
char *rb_operation_str = NULL;
+ dict_t *rsp_dict = NULL;
if (-1 == req->rpc_status) {
goto out;
@@ -1236,7 +1344,7 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
frame = (call_frame_t *) myframe;
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_replace_brick_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1244,7 +1352,7 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
local = frame->local;
GF_ASSERT (local);
- dict = local->u.replace_brick.dict;
+ dict = local->dict;
ret = dict_get_int32 (dict, "operation", (int32_t *)&replace_op);
if (ret) {
@@ -1263,11 +1371,33 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
case GF_REPLACE_OP_STATUS:
- status_reply = rsp.status;
if (rsp.op_ret || ret)
rb_operation_str = "replace-brick status unknown";
- else
+ else {
+ if (rsp.dict.dict_len) {
+ /* Unserialize the dictionary */
+ rsp_dict = dict_new ();
+
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
+ &rsp_dict);
+ if (ret < 0) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
+ ret = dict_get_str (rsp_dict, "status-reply",
+ &status_reply);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to"
+ "get status");
+ goto out;
+ }
+
rb_operation_str = status_reply;
+ }
break;
@@ -1327,12 +1457,16 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
out:
if (local) {
- dict_unref (local->u.replace_brick.dict);
- GF_FREE (local->u.replace_brick.volname);
+ dict_unref (local->dict);
cli_local_wipe (local);
}
cli_cmd_broadcast_response (ret);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
+ if (rsp_dict)
+ dict_unref (rsp_dict);
+
return ret;
}
@@ -1340,14 +1474,14 @@ static int
gf_cli3_1_log_filename_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_log_filename_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_log_filename_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1355,8 +1489,8 @@ gf_cli3_1_log_filename_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_DEBUG, "Received resp to log filename");
- if (rsp.op_ret && strcmp (rsp.errstr, ""))
- cli_out ("%s", rsp.errstr);
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ cli_out ("%s", rsp.op_errstr);
else
cli_out ("log filename : %s",
(rsp.op_ret) ? "unsuccessful": "successful");
@@ -1365,6 +1499,8 @@ gf_cli3_1_log_filename_cbk (struct rpc_req *req, struct iovec *iov,
out:
cli_cmd_broadcast_response (ret);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
return ret;
}
@@ -1399,14 +1535,14 @@ static int
gf_cli3_1_log_rotate_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_log_rotate_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_log_rotate_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1414,8 +1550,8 @@ gf_cli3_1_log_rotate_cbk (struct rpc_req *req, struct iovec *iov,
gf_log ("cli", GF_LOG_DEBUG, "Received resp to log rotate");
- if (rsp.op_ret && strcmp (rsp.errstr, ""))
- cli_out ("%s", rsp.errstr);
+ if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
+ cli_out ("%s", rsp.op_errstr);
else
cli_out ("log rotate %s", (rsp.op_ret) ? "unsuccessful":
"successful");
@@ -1424,6 +1560,9 @@ gf_cli3_1_log_rotate_cbk (struct rpc_req *req, struct iovec *iov,
out:
cli_cmd_broadcast_response (ret);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
+
return ret;
}
@@ -1431,14 +1570,14 @@ static int
gf_cli3_1_sync_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_sync_volume_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_sync_volume_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1577,14 +1716,18 @@ int
gf_cli3_1_quota_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_quota_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ char *limit_list = NULL;
+ int32_t type = 0;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_quota_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -1596,10 +1739,40 @@ gf_cli3_1_quota_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- if (rsp.type == GF_QUOTA_OPTION_TYPE_LIST) {
- if (rsp.limit_list) {
- gf_cli3_1_print_limit_list (rsp.volname,
- rsp.limit_list,
+ if (rsp.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
+
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get volname");
+
+ ret = dict_get_str (dict, "limit_list", &limit_list);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get limit_list");
+
+ ret = dict_get_int32 (dict, "type", &type);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get type");
+
+ if (type == GF_QUOTA_OPTION_TYPE_LIST) {
+ if (limit_list) {
+ gf_cli3_1_print_limit_list (volname,
+ limit_list,
rsp.op_errstr);
}
} else {
@@ -1614,6 +1787,10 @@ out:
ret = rsp.op_ret;
cli_cmd_broadcast_response (ret);
+
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
+
return ret;
}
@@ -1808,18 +1985,18 @@ gf_cli3_1_get_next_volume (call_frame_t *frame, xlator_t *this,
local = frame->local;
- if (!local || !local->u.get_vol.volname) {
+ if (!local || !local->get_vol.volname) {
cli_out ("No volumes present");
goto out;
}
- ctx->volname = local->u.get_vol.volname;
+ ctx->volname = local->get_vol.volname;
while (ctx->volname) {
ret = gf_cli3_1_get_volume (frame, this, ctx);
if (ret)
goto out;
- ctx->volname = local->u.get_vol.volname;
+ ctx->volname = local->get_vol.volname;
}
out:
@@ -1830,10 +2007,11 @@ int32_t
gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_get_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
cli_cmd_volume_get_ctx_t *ctx = NULL;
dict_t *dict = NULL;
+ int32_t flags = 0;
if (!frame || !this || !data) {
ret = -1;
@@ -1841,7 +2019,6 @@ gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this,
}
ctx = data;
- req.flags = ctx->flags;
dict = dict_new ();
if (!dict)
@@ -1853,6 +2030,13 @@ gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this,
goto out;
}
+ flags = ctx->flags;
+ ret = dict_set_int32 (dict, "flags", flags);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to set flags");
+ goto out;
+ }
+
ret = dict_allocate_and_serialize (dict,
&req.dict.dict_val,
(size_t *)&req.dict.dict_len);
@@ -1860,7 +2044,7 @@ gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_GET_VOLUME, NULL,
this, gf_cli3_1_get_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_get_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
@@ -1872,7 +2056,7 @@ int32_t
gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_create_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
cli_local_t *local = NULL;
@@ -1884,23 +2068,9 @@ gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this,
dict = dict_ref ((dict_t *)data);
- ret = dict_get_str (dict, "volname", &req.volname);
-
- if (ret)
- goto out;
-
- ret = dict_get_int32 (dict, "type", (int32_t *)&req.type);
-
- if (ret)
- goto out;
-
- ret = dict_get_int32 (dict, "count", &req.count);
- if (ret)
- goto out;
-
ret = dict_allocate_and_serialize (dict,
- &req.bricks.bricks_val,
- (size_t *)&req.bricks.bricks_len);
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
if (ret < 0) {
gf_log (this->name, GF_LOG_DEBUG,
"failed to get serialized length of dict");
@@ -1910,14 +2080,14 @@ gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this,
local = cli_local_get ();
if (local) {
- local->u.create_vol.dict = dict_ref (dict);
+ local->dict = dict_ref (dict);
frame->local = local;
}
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_CREATE_VOLUME, NULL,
this, gf_cli3_1_create_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_create_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
@@ -1927,8 +2097,8 @@ out:
if (dict)
dict_unref (dict);
- if (req.bricks.bricks_val) {
- GF_FREE (req.bricks.bricks_val);
+ if (req.dict.dict_val) {
+ GF_FREE (req.dict.dict_val);
}
return ret;
@@ -1938,9 +2108,10 @@ int32_t
gf_cli3_1_delete_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_delete_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
cli_local_t *local = NULL;
+ dict_t *dict = NULL;
if (!frame || !this || !data) {
ret = -1;
@@ -1949,19 +2120,36 @@ gf_cli3_1_delete_volume (call_frame_t *frame, xlator_t *this,
local = cli_local_get ();
+ dict = dict_new ();
+ ret = dict_set_str (dict, "volname", data);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_WARNING, "dict set failed");
+ goto out;
+ }
if (local) {
- local->u.delete_vol.volname = data;
+ local->dict = dict_ref (dict);
frame->local = local;
}
- req.volname = data;
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to get serialize dict");
+ goto out;
+ }
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_DELETE_VOLUME, NULL,
this, gf_cli3_1_delete_volume_cbk,
- (xdrproc_t)xdr_gf1_cli_delete_vol_req);
+ (xdrproc_t)xdr_gf_cli_req);
out:
+ if (dict)
+ dict_unref (dict);
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
@@ -1971,28 +2159,38 @@ int32_t
gf_cli3_1_start_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_start_vol_req *req = NULL;
+ gf_cli_req req = {{0,}};
int ret = 0;
cli_local_t *local = NULL;
+ dict_t *dict = NULL;
if (!frame || !this || !data) {
ret = -1;
goto out;
}
- req = data;
+ dict = data;
local = cli_local_get ();
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize dict");
+ goto out;
+ }
+
+
if (local) {
- local->u.start_vol.volname = req->volname;
- local->u.start_vol.flags = req->flags;
+ local->dict = dict_ref (dict);
frame->local = local;
}
- ret = cli_cmd_submit (req, frame, cli_rpc_prog,
+ ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_START_VOLUME, NULL,
this, gf_cli3_1_start_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_start_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
@@ -2004,28 +2202,38 @@ int32_t
gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_stop_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
cli_local_t *local = NULL;
+ dict_t *dict = data;
if (!frame || !this || !data) {
ret = -1;
goto out;
}
- req = *((gf1_cli_stop_vol_req*)data);
local = cli_local_get ();
+ dict = data;
if (local) {
- local->u.stop_vol.volname = req.volname;
- local->u.stop_vol.flags = req.flags;
+ local->dict = dict_ref (dict);
frame->local = local;
}
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *) &req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
+ goto out;
+ }
+
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_STOP_VOLUME, NULL,
this, gf_cli3_1_stop_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_stop_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
@@ -2037,12 +2245,14 @@ int32_t
gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_defrag_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
cli_local_t *local = NULL;
char *volname = NULL;
char *cmd_str = NULL;
dict_t *dict = NULL;
+ gf_cli_defrag_type cmd = 0;
+ dict_t *req_dict = NULL;
if (!frame || !this || !data) {
ret = -1;
@@ -2062,44 +2272,71 @@ gf_cli3_1_defrag_volume (call_frame_t *frame, xlator_t *this,
}
if (strcmp (cmd_str, "start") == 0) {
- req.cmd = GF_DEFRAG_CMD_START;
+ cmd = GF_DEFRAG_CMD_START;
ret = dict_get_str (dict, "start-type", &cmd_str);
if (!ret) {
if (strcmp (cmd_str, "fix-layout") == 0) {
- req.cmd = GF_DEFRAG_CMD_START_LAYOUT_FIX;
+ cmd = GF_DEFRAG_CMD_START_LAYOUT_FIX;
}
if (strcmp (cmd_str, "migrate-data") == 0) {
- req.cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA;
+ cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA;
}
if (strcmp (cmd_str, "migrate-data-force") == 0) {
- req.cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA_FORCE;
+ cmd = GF_DEFRAG_CMD_START_MIGRATE_DATA_FORCE;
}
}
goto done;
}
if (strcmp (cmd_str, "stop") == 0) {
- req.cmd = GF_DEFRAG_CMD_STOP;
+ cmd = GF_DEFRAG_CMD_STOP;
goto done;
}
if (strcmp (cmd_str, "status") == 0) {
- req.cmd = GF_DEFRAG_CMD_STATUS;
+ cmd = GF_DEFRAG_CMD_STATUS;
}
done:
local = cli_local_get ();
+ req_dict = dict_new ();
+ if (!req_dict) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_set_str (req_dict, "volname", volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set dict");
+ goto out;
+ }
+
+ ret = dict_set_int32 (req_dict, "rebalance-command", (int32_t) cmd);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set dict");
+ goto out;
+ }
+
if (local) {
- local->u.defrag_vol.volname = gf_strdup (volname);
- local->u.defrag_vol.cmd = req.cmd;
+ local->dict = dict_ref (req_dict);
frame->local = local;
}
- req.volname = volname;
+ ret = dict_allocate_and_serialize (req_dict,
+ &req.dict.dict_val,
+ (size_t *) &req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
+ goto out;
+ }
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_DEFRAG_VOLUME, NULL,
this, gf_cli3_1_defrag_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_defrag_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
@@ -2111,7 +2348,7 @@ int32_t
gf_cli3_1_rename_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_rename_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -2122,20 +2359,21 @@ gf_cli3_1_rename_volume (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "old-volname", &req.old_volname);
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *) &req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
- if (ret)
goto out;
+ }
- ret = dict_get_str (dict, "new-volname", &req.new_volname);
-
- if (ret)
- goto out;
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_RENAME_VOLUME, NULL,
this, gf_cli3_1_rename_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_rename_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
@@ -2147,7 +2385,7 @@ int32_t
gf_cli3_1_reset_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_reset_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -2158,11 +2396,6 @@ gf_cli3_1_reset_volume (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
-
- if (ret)
- goto out;
-
ret = dict_allocate_and_serialize (dict,
&req.dict.dict_val,
(size_t *)&req.dict.dict_len);
@@ -2175,7 +2408,7 @@ gf_cli3_1_reset_volume (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_RESET_VOLUME, NULL,
this, gf_cli3_1_reset_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_reset_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
@@ -2187,7 +2420,7 @@ int32_t
gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_set_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -2198,11 +2431,6 @@ gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
-
- if (ret)
- goto out;
-
ret = dict_allocate_and_serialize (dict,
&req.dict.dict_val,
(size_t *)&req.dict.dict_len);
@@ -2215,7 +2443,7 @@ gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_SET_VOLUME, NULL,
this, gf_cli3_1_set_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_set_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
@@ -2227,9 +2455,11 @@ int32_t
gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_add_brick_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
+ char *volname = NULL;
+ int32_t count = 0;
if (!frame || !this || !data) {
ret = -1;
@@ -2238,19 +2468,19 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
+ ret = dict_get_str (dict, "volname", &volname);
if (ret)
goto out;
- ret = dict_get_int32 (dict, "count", &req.count);
+ ret = dict_get_int32 (dict, "count", &count);
if (ret)
goto out;
ret = dict_allocate_and_serialize (dict,
- &req.bricks.bricks_val,
- (size_t *)&req.bricks.bricks_len);
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
if (ret < 0) {
gf_log (this->name, GF_LOG_DEBUG,
"failed to get serialized length of dict");
@@ -2260,13 +2490,13 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_ADD_BRICK, NULL,
this, gf_cli3_1_add_brick_cbk,
- (xdrproc_t) xdr_gf1_cli_add_brick_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
- if (req.bricks.bricks_val) {
- GF_FREE (req.bricks.bricks_val);
+ if (req.dict.dict_val) {
+ GF_FREE (req.dict.dict_val);
}
return ret;
@@ -2276,12 +2506,14 @@ int32_t
gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_remove_brick_req req = {0,};
- gf1_cli_defrag_vol_req status_req = {0,};
+ gf_cli_req req = {{0,}};;
+ gf_cli_req status_req = {{0,}};;
int ret = 0;
dict_t *dict = NULL;
int32_t command = 0;
char *volname = NULL;
+ dict_t *req_dict = NULL;
+ int32_t cmd = 0;
if (!frame || !this || !data) {
ret = -1;
@@ -2294,20 +2526,15 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this,
if (ret)
goto out;
- ret = dict_get_int32 (dict, "count", &req.count);
- if (ret)
- goto out;
-
ret = dict_get_int32 (dict, "command", &command);
if (ret)
goto out;
if (command != GF_OP_CMD_STATUS) {
- req.volname = volname;
ret = dict_allocate_and_serialize (dict,
- &req.bricks.bricks_val,
- (size_t *)&req.bricks.bricks_len);
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
if (ret < 0) {
gf_log (this->name, GF_LOG_DEBUG,
"failed to get serialized length of dict");
@@ -2317,26 +2544,61 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_REMOVE_BRICK, NULL,
this, gf_cli3_1_remove_brick_cbk,
- (xdrproc_t) xdr_gf1_cli_remove_brick_req);
+ (xdrproc_t) xdr_gf_cli_req);
} else {
/* Need rebalance status to e sent :-) */
- status_req.volname = volname;
- status_req.cmd = GF_DEFRAG_CMD_STATUS;
+ req_dict = dict_new ();
+ if (!req_dict) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_set_str (req_dict, "volname", volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set dict");
+ goto out;
+ }
+
+ cmd |= GF_DEFRAG_CMD_STATUS;
+
+ ret = dict_set_int32 (req_dict, "rebalance-command", (int32_t) cmd);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set dict");
+ goto out;
+ }
+
+ ret = dict_allocate_and_serialize (req_dict,
+ &status_req.dict.dict_val,
+ (size_t *) &status_req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
+ goto out;
+ }
ret = cli_cmd_submit (&status_req, frame, cli_rpc_prog,
GLUSTER_CLI_DEFRAG_VOLUME, NULL,
this, gf_cli3_remove_brick_status_cbk,
- (xdrproc_t) xdr_gf1_cli_defrag_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
}
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
- if (req.bricks.bricks_val) {
- GF_FREE (req.bricks.bricks_val);
+ if (req.dict.dict_val) {
+ GF_FREE (req.dict.dict_val);
}
+ if (status_req.dict.dict_val)
+ GF_FREE (status_req.dict.dict_val);
+
+ if (req_dict)
+ dict_unref (req_dict);
+
return ret;
}
@@ -2344,12 +2606,14 @@ int32_t
gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_replace_brick_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
cli_local_t *local = NULL;
dict_t *dict = NULL;
char *src_brick = NULL;
char *dst_brick = NULL;
+ char *volname = NULL;
+ int32_t op = 0;
if (!frame || !this || !data) {
ret = -1;
@@ -2366,30 +2630,22 @@ gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this,
goto out;
}
- local->u.replace_brick.dict = dict_ref (dict);
+ local->dict = dict_ref (dict);
frame->local = local;
- ret = dict_get_int32 (dict, "operation", (int32_t *)&req.op);
+ ret = dict_get_int32 (dict, "operation", &op);
if (ret) {
gf_log (this->name, GF_LOG_DEBUG,
"dict_get on operation failed");
goto out;
}
- ret = dict_get_str (dict, "volname", &req.volname);
+ ret = dict_get_str (dict, "volname", &volname);
if (ret) {
gf_log (this->name, GF_LOG_DEBUG,
"dict_get on volname failed");
goto out;
}
- local->u.replace_brick.volname = gf_strdup (req.volname);
- if (!local->u.replace_brick.volname) {
- gf_log (this->name, GF_LOG_ERROR,
- "Out of memory");
- ret = -1;
- goto out;
- }
-
ret = dict_get_str (dict, "src-brick", &src_brick);
if (ret) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -2407,12 +2663,12 @@ gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_DEBUG,
"Recevied command replace-brick %s with "
"%s with operation=%d", src_brick,
- dst_brick, req.op);
+ dst_brick, op);
ret = dict_allocate_and_serialize (dict,
- &req.bricks.bricks_val,
- (size_t *)&req.bricks.bricks_len);
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
if (ret < 0) {
gf_log (this->name, GF_LOG_DEBUG,
"failed to get serialized length of dict");
@@ -2422,13 +2678,13 @@ gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_REPLACE_BRICK, NULL,
this, gf_cli3_1_replace_brick_cbk,
- (xdrproc_t) xdr_gf1_cli_replace_brick_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
- if (req.bricks.bricks_val) {
- GF_FREE (req.bricks.bricks_val);
+ if (req.dict.dict_val) {
+ GF_FREE (req.dict.dict_val);
}
return ret;
@@ -2438,7 +2694,7 @@ int32_t
gf_cli3_1_log_filename (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_log_filename_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -2449,26 +2705,25 @@ gf_cli3_1_log_filename (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
- if (ret)
- goto out;
-
- ret = dict_get_str (dict, "brick", &req.brick);
- if (ret)
- req.brick = "";
-
- ret = dict_get_str (dict, "path", &req.path);
- if (ret)
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to serialize dict");
goto out;
+ }
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_LOG_FILENAME, NULL,
this, gf_cli3_1_log_filename_cbk,
- (xdrproc_t) xdr_gf1_cli_log_filename_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
+
return ret;
}
@@ -2476,13 +2731,13 @@ static int
gf_cli3_1_log_level_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_log_level_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
if (req->rpc_status == -1)
goto out;
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_log_level_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("cli", GF_LOG_ERROR, "log level response error");
goto out;
@@ -2507,7 +2762,7 @@ int32_t
gf_cli3_1_log_level (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_log_level_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -2518,25 +2773,24 @@ gf_cli3_1_log_level (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
- if (ret)
- goto out;
-
- ret = dict_get_str (dict, "xlator", &req.xlator);
- if (ret)
- goto out;
-
- ret = dict_get_str (dict, "loglevel", &req.loglevel);
- if (ret)
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to serialize dict");
goto out;
+ }
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_LOG_LEVEL, NULL,
this, gf_cli3_1_log_level_cbk,
- (xdrproc_t) xdr_gf1_cli_log_level_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning: %d", ret);
+
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
return ret;
}
@@ -2579,7 +2833,7 @@ int32_t
gf_cli3_1_log_rotate (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_log_locate_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -2590,23 +2844,26 @@ gf_cli3_1_log_rotate (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
- if (ret)
- goto out;
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
- ret = dict_get_str (dict, "brick", &req.brick);
- if (ret)
- req.brick = "";
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to serialize dict");
+ goto out;
+ }
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_LOG_ROTATE, NULL,
this, gf_cli3_1_log_rotate_cbk,
- (xdrproc_t) xdr_gf1_cli_log_rotate_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
return ret;
}
@@ -2615,19 +2872,33 @@ gf_cli3_1_sync_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
int ret = 0;
+ gf_cli_req req = {{0,}};
+ dict_t *dict = NULL;
if (!frame || !this || !data) {
ret = -1;
goto out;
}
- ret = cli_cmd_submit ((gf1_cli_sync_volume_req*)data, frame,
+ dict = data;
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to serialize dict");
+ goto out;
+ }
+
+ ret = cli_cmd_submit (&req, frame,
cli_rpc_prog, GLUSTER_CLI_SYNC_VOLUME,
NULL, this, gf_cli3_1_sync_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_sync_volume_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
return ret;
}
@@ -2666,7 +2937,7 @@ int32_t
gf_cli3_1_quota (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_quota_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -2677,11 +2948,6 @@ gf_cli3_1_quota (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
-
- if (ret)
- goto out;
-
ret = dict_allocate_and_serialize (dict,
&req.dict.dict_val,
(size_t *)&req.dict.dict_len);
@@ -2694,7 +2960,7 @@ gf_cli3_1_quota (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_QUOTA, NULL,
this, gf_cli3_1_quota_cbk,
- (xdrproc_t) xdr_gf1_cli_quota_req);
+ (xdrproc_t) xdr_gf_cli_req);
GF_FREE (req.dict.dict_val);
out:
@@ -2946,18 +3212,19 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
int ret = 0;
- gf1_cli_gsync_set_rsp rsp = {0, };
+ gf_cli_rsp rsp = {0, };
dict_t *dict = NULL;
char *gsync_status = NULL;
char *master = NULL;
char *slave = NULL;
+ int32_t type = 0;
if (req->rpc_status == -1) {
ret = -1;
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_gsync_set_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR,
"Unable to get response structure");
@@ -2989,8 +3256,13 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
else
ret = 0;
+ ret = dict_get_int32 (dict, "type", &type);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get type");
+ goto out;
+ }
- switch (rsp.type) {
+ switch (type) {
case GF_GSYNC_OPTION_TYPE_START:
case GF_GSYNC_OPTION_TYPE_STOP:
if (dict_get_str (dict, "master", &master) != 0)
@@ -3000,7 +3272,7 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
cli_out ("%s " GEOREP " session between %s & %s"
" has been successful",
- rsp.type == GF_GSYNC_OPTION_TYPE_START ?
+ type == GF_GSYNC_OPTION_TYPE_START ?
"Starting" : "Stopping",
master, slave);
break;
@@ -3020,6 +3292,9 @@ out:
cli_cmd_broadcast_response (ret);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
+
return ret;
}
@@ -3029,7 +3304,7 @@ gf_cli3_1_gsync_set (call_frame_t *frame, xlator_t *this,
{
int ret = 0;
dict_t *dict = NULL;
- gf1_cli_gsync_set_req req;
+ gf_cli_req req = {{0,}};
if (!frame || !this || !data) {
ret = -1;
@@ -3051,9 +3326,12 @@ gf_cli3_1_gsync_set (call_frame_t *frame, xlator_t *this,
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_GSYNC_SET, NULL,
this, gf_cli3_1_gsync_set_cbk,
- (xdrproc_t) xdr_gf1_cli_gsync_set_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
+
return ret;
}
@@ -3269,7 +3547,7 @@ int32_t
gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_stats_volume_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
dict_t *dict = NULL;
gf1_cli_stats_op op = GF_CLI_STATS_NONE;
@@ -3283,7 +3561,7 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
gf_log ("cli", GF_LOG_DEBUG, "Received resp to profile");
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_stats_volume_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -3296,8 +3574,8 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = dict_unserialize (rsp.stats_info.stats_info_val,
- rsp.stats_info.stats_info_len,
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
&dict);
if (ret) {
@@ -3305,7 +3583,7 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
"Unable to allocate memory");
goto out;
} else {
- dict->extra_stdfree = rsp.stats_info.stats_info_val;
+ dict->extra_stdfree = rsp.dict.dict_val;
}
ret = dict_get_str (dict, "volname", &volname);
@@ -3387,7 +3665,7 @@ int32_t
gf_cli3_1_profile_volume (call_frame_t *frame, xlator_t *this, void *data)
{
int ret = -1;
- gf1_cli_stats_volume_req req = {0,};
+ gf_cli_req req = {{0,}};
dict_t *dict = NULL;
GF_ASSERT (frame);
@@ -3397,21 +3675,29 @@ gf_cli3_1_profile_volume (call_frame_t *frame, xlator_t *this, void *data)
if (!frame || !this || !data)
goto out;
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
- if (ret)
- goto out;
- ret = dict_get_int32 (dict, "op", (int32_t*)&req.op);
- if (ret)
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
goto out;
+ }
+
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_PROFILE_VOLUME, NULL,
this, gf_cli3_1_profile_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_stats_volume_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
return ret;
}
@@ -3419,7 +3705,7 @@ int32_t
gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_stats_volume_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
dict_t *dict = NULL;
gf1_cli_stats_op op = GF_CLI_STATS_NONE;
@@ -3448,7 +3734,7 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
gf_log ("cli", GF_LOG_DEBUG, "Received resp to top");
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_stats_volume_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "Unable to decode response");
goto out;
@@ -3469,8 +3755,8 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = dict_unserialize (rsp.stats_info.stats_info_val,
- rsp.stats_info.stats_info_len,
+ ret = dict_unserialize (rsp.dict.dict_val,
+ rsp.dict.dict_len,
&dict);
if (ret) {
@@ -3611,8 +3897,8 @@ out:
if (dict)
dict_unref (dict);
- if (rsp.stats_info.stats_info_val)
- free (rsp.stats_info.stats_info_val);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
return ret;
}
@@ -3620,7 +3906,7 @@ int32_t
gf_cli3_1_top_volume (call_frame_t *frame, xlator_t *this, void *data)
{
int ret = -1;
- gf1_cli_stats_volume_req req = {0,};
+ gf_cli_req req = {{0,}};
dict_t *dict = NULL;
GF_ASSERT (frame);
@@ -3630,25 +3916,27 @@ gf_cli3_1_top_volume (call_frame_t *frame, xlator_t *this, void *data)
if (!frame || !this || !data)
goto out;
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
- if (ret)
- goto out;
- ret = dict_get_int32 (dict, "op", (int32_t*)&req.op);
- if (ret)
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
goto out;
+ }
- ret = dict_allocate_and_serialize (dict,
- &req.dict_req.dict_req_val,
- (size_t *)&req.dict_req.dict_req_len);
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_PROFILE_VOLUME, NULL,
this, gf_cli3_1_top_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_stats_volume_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
return ret;
}
@@ -3708,7 +3996,7 @@ static int
gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_status_volume_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
dict_t *dict = NULL;
char *hostname = NULL;
@@ -3725,7 +4013,7 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,
if (req->rpc_status == -1)
goto out;
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_status_volume_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("cli", GF_LOG_ERROR, "Volume status response error");
goto out;
@@ -3803,7 +4091,7 @@ int32_t
gf_cli3_1_status_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_status_volume_req req = {0,};
+ gf_cli_req req = {{0,}};
int ret = 0;
dict_t *dict = NULL;
@@ -3814,14 +4102,19 @@ gf_cli3_1_status_volume (call_frame_t *frame, xlator_t *this,
dict = data;
- ret = dict_get_str (dict, "volname", &req.volname);
- if (ret)
- goto out;
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+ goto out;
+ }
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_STATUS_VOLUME, NULL,
this, gf_cli3_1_status_cbk,
- (xdrproc_t)xdr_gf1_cli_status_volume_req);
+ (xdrproc_t)xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning: %d", ret);
@@ -3961,17 +4254,18 @@ int
gf_cli3_1_heal_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_heal_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = 0;
cli_local_t *local = NULL;
char *volname = NULL;
call_frame_t *frame = NULL;
+ dict_t *dict = NULL;
if (-1 == req->rpc_status) {
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_heal_vol_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log ("", GF_LOG_ERROR, "error");
goto out;
@@ -3985,7 +4279,13 @@ gf_cli3_1_heal_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
if (local)
- volname = local->u.heal_vol.volname;
+ dict = local->dict;
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
+ goto out;
+ }
gf_log ("cli", GF_LOG_INFO, "Received resp to heal volume");
@@ -4001,10 +4301,12 @@ out:
cli_cmd_broadcast_response (ret);
if (local)
cli_local_wipe (local);
- if (rsp.volname)
- free (rsp.volname);
+ if (rsp.dict.dict_val)
+ free (rsp.dict.dict_val);
if (rsp.op_errstr)
free (rsp.op_errstr);
+ if (dict)
+ dict_unref (dict);
return ret;
}
@@ -4012,31 +4314,45 @@ int32_t
gf_cli3_1_heal_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_heal_vol_req *req = NULL;
+ gf_cli_req req = {{0,}};
int ret = 0;
cli_local_t *local = NULL;
+ dict_t *dict = NULL;
if (!frame || !this || !data) {
ret = -1;
goto out;
}
- req = data;
+ dict = data;
local = cli_local_get ();
if (local) {
- local->u.heal_vol.volname = req->volname;
+ local->dict = dict_ref (dict);
frame->local = local;
}
- ret = cli_cmd_submit (req, frame, cli_rpc_prog,
+ ret = dict_allocate_and_serialize (dict,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
+ goto out;
+ }
+
+ ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_HEAL_VOLUME, NULL,
this, gf_cli3_1_heal_volume_cbk,
- (xdrproc_t) xdr_gf1_cli_heal_vol_req);
+ (xdrproc_t) xdr_gf_cli_req);
out:
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
+
return ret;
}
@@ -4044,13 +4360,13 @@ int32_t
gf_cli3_1_statedump_volume_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
- gf1_cli_statedump_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
int ret = -1;
if (-1 == req->rpc_status)
goto out;
ret = xdr_to_generic (*iov, &rsp,
- (xdrproc_t)xdr_gf1_cli_statedump_vol_rsp);
+ (xdrproc_t)xdr_gf_cli_rsp);
if (ret < 0) {
gf_log (THIS->name, GF_LOG_ERROR, "XDR decoding failed");
goto out;
@@ -4072,11 +4388,8 @@ int32_t
gf_cli3_1_statedump_volume (call_frame_t *frame, xlator_t *this,
void *data)
{
- gf1_cli_statedump_vol_req req = {0,};
+ gf_cli_req req = {{0,}};
dict_t *options = NULL;
- char *volname = NULL;
- char *option_str = NULL;
- int option_cnt = 0;
int ret = -1;
if (!frame || !this || !data)
@@ -4084,30 +4397,28 @@ gf_cli3_1_statedump_volume (call_frame_t *frame, xlator_t *this,
options = data;
- ret = dict_get_str (options, "volname", &volname);
- if (ret)
- goto out;
- req.volname = volname;
-
- ret = dict_get_str (options, "options", &option_str);
- if (ret)
- goto out;
- req.options = option_str;
+ ret = dict_allocate_and_serialize (options,
+ &req.dict.dict_val,
+ (size_t *)&req.dict.dict_len);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to serialize the data");
- ret = dict_get_int32 (options, "option-cnt", &option_cnt);
- if (ret)
goto out;
- req.option_cnt = option_cnt;
+ }
ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
GLUSTER_CLI_STATEDUMP_VOLUME, NULL,
this, gf_cli3_1_statedump_volume_cbk,
- (xdrproc_t)xdr_gf1_cli_statedump_vol_req);
+ (xdrproc_t)xdr_gf_cli_req);
out:
if (options)
dict_destroy (options);
gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ if (req.dict.dict_val)
+ GF_FREE (req.dict.dict_val);
return ret;
}
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 0a2fdb54b07..70310f103ed 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -116,44 +116,12 @@ struct cli_state {
};
struct cli_local {
- union {
- struct {
- dict_t *dict;
- } create_vol;
-
- struct {
- char *volname;
- int flags;
- } start_vol;
-
- struct {
- char *volname;
- int flags;
- } stop_vol;
-
- struct {
- char *volname;
- } delete_vol;
-
- struct {
- char *volname;
- int cmd;
- } defrag_vol;
-
- struct {
- char *volname;
- dict_t *dict;
- } replace_brick;
-
- struct {
- char *volname;
- int flags;
- } get_vol;
-
- struct {
- char *volname;
- }heal_vol;
- } u;
+ struct {
+ char *volname;
+ int flags;
+ } get_vol;
+
+ dict_t *dict;
};
typedef struct cli_local cli_local_t;
diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c
index d325ac42ae2..1062b6b3c5d 100644
--- a/rpc/xdr/src/cli1-xdr.c
+++ b/rpc/xdr/src/cli1-xdr.c
@@ -177,6 +177,34 @@ xdr_gf1_cli_top_op (XDR *xdrs, gf1_cli_top_op *objp)
}
bool_t
+xdr_gf_cli_req (XDR *xdrs, gf_cli_req *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_gf_cli_rsp (XDR *xdrs, gf_cli_rsp *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_gf1_cli_probe_req (XDR *xdrs, gf1_cli_probe_req *objp)
{
register int32_t *buf;
@@ -304,431 +332,6 @@ xdr_gf1_cli_peer_list_rsp (XDR *xdrs, gf1_cli_peer_list_rsp *objp)
}
bool_t
-xdr_gf1_cli_get_vol_req (XDR *xdrs, gf1_cli_get_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->flags))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_get_vol_rsp (XDR *xdrs, gf1_cli_get_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->volumes.volumes_val, (u_int *) &objp->volumes.volumes_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_create_vol_req (XDR *xdrs, gf1_cli_create_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_gf1_cluster_type (xdrs, &objp->type))
- return FALSE;
- if (!xdr_int (xdrs, &objp->count))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->bricks.bricks_val, (u_int *) &objp->bricks.bricks_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_create_vol_rsp (XDR *xdrs, gf1_cli_create_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_delete_vol_req (XDR *xdrs, gf1_cli_delete_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_delete_vol_rsp (XDR *xdrs, gf1_cli_delete_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_start_vol_req (XDR *xdrs, gf1_cli_start_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->flags))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_start_vol_rsp (XDR *xdrs, gf1_cli_start_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_stop_vol_req (XDR *xdrs, gf1_cli_stop_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->flags))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_stop_vol_rsp (XDR *xdrs, gf1_cli_stop_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_rename_vol_req (XDR *xdrs, gf1_cli_rename_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->old_volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->new_volname, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_rename_vol_rsp (XDR *xdrs, gf1_cli_rename_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_defrag_vol_req (XDR *xdrs, gf1_cli_defrag_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->cmd))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_defrag_vol_rsp (XDR *xdrs, gf1_cli_defrag_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->files))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->size))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->lookedup_files))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf2_cli_defrag_vol_rsp (XDR *xdrs, gf2_cli_defrag_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->files))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->size))
- return FALSE;
- if (!xdr_u_quad_t (xdrs, &objp->lookedup_files))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_add_brick_req (XDR *xdrs, gf1_cli_add_brick_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->count))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->bricks.bricks_val, (u_int *) &objp->bricks.bricks_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_add_brick_rsp (XDR *xdrs, gf1_cli_add_brick_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_remove_brick_req (XDR *xdrs, gf1_cli_remove_brick_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->count))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->bricks.bricks_val, (u_int *) &objp->bricks.bricks_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_remove_brick_rsp (XDR *xdrs, gf1_cli_remove_brick_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_replace_brick_req (XDR *xdrs, gf1_cli_replace_brick_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_gf1_cli_replace_op (xdrs, &objp->op))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->bricks.bricks_val, (u_int *) &objp->bricks.bricks_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_replace_brick_rsp (XDR *xdrs, gf1_cli_replace_brick_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->status, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_reset_vol_req (XDR *xdrs, gf1_cli_reset_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_reset_vol_rsp (XDR *xdrs, gf1_cli_reset_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_set_vol_req (XDR *xdrs, gf1_cli_set_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_set_vol_rsp (XDR *xdrs, gf1_cli_set_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_log_filename_req (XDR *xdrs, gf1_cli_log_filename_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->brick, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->path, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_log_filename_rsp (XDR *xdrs, gf1_cli_log_filename_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
xdr_gf1_cli_log_locate_req (XDR *xdrs, gf1_cli_log_locate_req *objp)
{
register int32_t *buf;
@@ -742,21 +345,6 @@ xdr_gf1_cli_log_locate_req (XDR *xdrs, gf1_cli_log_locate_req *objp)
}
bool_t
-xdr_gf1_cli_sync_volume_req (XDR *xdrs, gf1_cli_sync_volume_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->flags))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->hostname, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
xdr_gf1_cli_log_locate_rsp (XDR *xdrs, gf1_cli_log_locate_rsp *objp)
{
register int32_t *buf;
@@ -772,49 +360,6 @@ xdr_gf1_cli_log_locate_rsp (XDR *xdrs, gf1_cli_log_locate_rsp *objp)
}
bool_t
-xdr_gf1_cli_log_rotate_req (XDR *xdrs, gf1_cli_log_rotate_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->brick, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_log_rotate_rsp (XDR *xdrs, gf1_cli_log_rotate_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_sync_volume_rsp (XDR *xdrs, gf1_cli_sync_volume_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
xdr_gf1_cli_fsm_log_req (XDR *xdrs, gf1_cli_fsm_log_req *objp)
{
register int32_t *buf;
@@ -843,102 +388,6 @@ xdr_gf1_cli_fsm_log_rsp (XDR *xdrs, gf1_cli_fsm_log_rsp *objp)
}
bool_t
-xdr_gf1_cli_gsync_set_req (XDR *xdrs, gf1_cli_gsync_set_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_gsync_set_rsp (XDR *xdrs, gf1_cli_gsync_set_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->type))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_stats_volume_req (XDR *xdrs, gf1_cli_stats_volume_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_gf1_cli_stats_op (xdrs, &objp->op))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict_req.dict_req_val, (u_int *) &objp->dict_req.dict_req_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_stats_volume_rsp (XDR *xdrs, gf1_cli_stats_volume_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->stats_info.stats_info_val, (u_int *) &objp->stats_info.stats_info_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_quota_req (XDR *xdrs, gf1_cli_quota_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_quota_rsp (XDR *xdrs, gf1_cli_quota_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->limit_list, ~0))
- return FALSE;
- if (!xdr_gf_quota_type (xdrs, &objp->type))
- return FALSE;
- return TRUE;
-}
-
-bool_t
xdr_gf1_cli_getwd_req (XDR *xdrs, gf1_cli_getwd_req *objp)
{
register int32_t *buf;
@@ -965,66 +414,6 @@ xdr_gf1_cli_getwd_rsp (XDR *xdrs, gf1_cli_getwd_rsp *objp)
}
bool_t
-xdr_gf1_cli_log_level_req (XDR *xdrs, gf1_cli_log_level_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->xlator, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->loglevel, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_log_level_rsp (XDR *xdrs, gf1_cli_log_level_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_status_volume_req (XDR *xdrs, gf1_cli_status_volume_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_status_volume_rsp (XDR *xdrs, gf1_cli_status_volume_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
xdr_gf1_cli_mount_req (XDR *xdrs, gf1_cli_mount_req *objp)
{
register int32_t *buf;
@@ -1077,67 +466,3 @@ xdr_gf1_cli_umount_rsp (XDR *xdrs, gf1_cli_umount_rsp *objp)
return FALSE;
return TRUE;
}
-
-bool_t
-xdr_gf1_cli_heal_vol_req (XDR *xdrs, gf1_cli_heal_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_heal_vol_rsp (XDR *xdrs, gf1_cli_heal_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_statedump_vol_req (XDR *xdrs, gf1_cli_statedump_vol_req *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->options, ~0))
- return FALSE;
- if (!xdr_int (xdrs, &objp->option_cnt))
- return FALSE;
- return TRUE;
-}
-
-bool_t
-xdr_gf1_cli_statedump_vol_rsp (XDR *xdrs, gf1_cli_statedump_vol_rsp *objp)
-{
- register int32_t *buf;
- buf = NULL;
-
- if (!xdr_int (xdrs, &objp->op_ret))
- return FALSE;
- if (!xdr_int (xdrs, &objp->op_errno))
- return FALSE;
- if (!xdr_string (xdrs, &objp->volname, ~0))
- return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
- return FALSE;
- return TRUE;
-}
diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h
index ae8c436fc1d..db63283a1a6 100644
--- a/rpc/xdr/src/cli1-xdr.h
+++ b/rpc/xdr/src/cli1-xdr.h
@@ -135,7 +135,7 @@ enum gf1_cli_gsync_set {
GF_GSYNC_OPTION_TYPE_STOP = 2,
GF_GSYNC_OPTION_TYPE_CONFIG = 3,
GF_GSYNC_OPTION_TYPE_STATUS = 4,
- GF_GSYNC_OPTION_TYPE_ROTATE = 5,
+ GF_GSYNC_OPTION_TYPE_ROTATE = 5,
};
typedef enum gf1_cli_gsync_set gf1_cli_gsync_set;
@@ -160,6 +160,25 @@ enum gf1_cli_top_op {
};
typedef enum gf1_cli_top_op gf1_cli_top_op;
+struct gf_cli_req {
+ struct {
+ u_int dict_len;
+ char *dict_val;
+ } dict;
+};
+typedef struct gf_cli_req gf_cli_req;
+
+struct gf_cli_rsp {
+ int op_ret;
+ int op_errno;
+ char *op_errstr;
+ struct {
+ u_int dict_len;
+ char *dict_val;
+ } dict;
+};
+typedef struct gf_cli_rsp gf_cli_rsp;
+
struct gf1_cli_probe_req {
char *hostname;
int port;
@@ -207,245 +226,12 @@ struct gf1_cli_peer_list_rsp {
};
typedef struct gf1_cli_peer_list_rsp gf1_cli_peer_list_rsp;
-struct gf1_cli_get_vol_req {
- int flags;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_get_vol_req gf1_cli_get_vol_req;
-
-struct gf1_cli_get_vol_rsp {
- int op_ret;
- int op_errno;
- struct {
- u_int volumes_len;
- char *volumes_val;
- } volumes;
-};
-typedef struct gf1_cli_get_vol_rsp gf1_cli_get_vol_rsp;
-
-struct gf1_cli_create_vol_req {
- char *volname;
- gf1_cluster_type type;
- int count;
- struct {
- u_int bricks_len;
- char *bricks_val;
- } bricks;
-};
-typedef struct gf1_cli_create_vol_req gf1_cli_create_vol_req;
-
-struct gf1_cli_create_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
-};
-typedef struct gf1_cli_create_vol_rsp gf1_cli_create_vol_rsp;
-
-struct gf1_cli_delete_vol_req {
- char *volname;
-};
-typedef struct gf1_cli_delete_vol_req gf1_cli_delete_vol_req;
-
-struct gf1_cli_delete_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
-};
-typedef struct gf1_cli_delete_vol_rsp gf1_cli_delete_vol_rsp;
-
-struct gf1_cli_start_vol_req {
- char *volname;
- int flags;
-};
-typedef struct gf1_cli_start_vol_req gf1_cli_start_vol_req;
-
-struct gf1_cli_start_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
-};
-typedef struct gf1_cli_start_vol_rsp gf1_cli_start_vol_rsp;
-
-struct gf1_cli_stop_vol_req {
- char *volname;
- int flags;
-};
-typedef struct gf1_cli_stop_vol_req gf1_cli_stop_vol_req;
-
-struct gf1_cli_stop_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
-};
-typedef struct gf1_cli_stop_vol_rsp gf1_cli_stop_vol_rsp;
-
-struct gf1_cli_rename_vol_req {
- char *old_volname;
- char *new_volname;
-};
-typedef struct gf1_cli_rename_vol_req gf1_cli_rename_vol_req;
-
-struct gf1_cli_rename_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
-};
-typedef struct gf1_cli_rename_vol_rsp gf1_cli_rename_vol_rsp;
-
-struct gf1_cli_defrag_vol_req {
- int cmd;
- char *volname;
-};
-typedef struct gf1_cli_defrag_vol_req gf1_cli_defrag_vol_req;
-
-struct gf1_cli_defrag_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- u_quad_t files;
- u_quad_t size;
- u_quad_t lookedup_files;
-};
-typedef struct gf1_cli_defrag_vol_rsp gf1_cli_defrag_vol_rsp;
-
-struct gf2_cli_defrag_vol_rsp {
- int op_ret;
- int op_errno;
- char *op_errstr;
- char *volname;
- u_quad_t files;
- u_quad_t size;
- u_quad_t lookedup_files;
-};
-typedef struct gf2_cli_defrag_vol_rsp gf2_cli_defrag_vol_rsp;
-
-struct gf1_cli_add_brick_req {
- char *volname;
- int count;
- struct {
- u_int bricks_len;
- char *bricks_val;
- } bricks;
-};
-typedef struct gf1_cli_add_brick_req gf1_cli_add_brick_req;
-
-struct gf1_cli_add_brick_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
-};
-typedef struct gf1_cli_add_brick_rsp gf1_cli_add_brick_rsp;
-
-struct gf1_cli_remove_brick_req {
- char *volname;
- int count;
- struct {
- u_int bricks_len;
- char *bricks_val;
- } bricks;
-};
-typedef struct gf1_cli_remove_brick_req gf1_cli_remove_brick_req;
-
-struct gf1_cli_remove_brick_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
-};
-typedef struct gf1_cli_remove_brick_rsp gf1_cli_remove_brick_rsp;
-
-struct gf1_cli_replace_brick_req {
- char *volname;
- gf1_cli_replace_op op;
- struct {
- u_int bricks_len;
- char *bricks_val;
- } bricks;
-};
-typedef struct gf1_cli_replace_brick_req gf1_cli_replace_brick_req;
-
-struct gf1_cli_replace_brick_rsp {
- int op_ret;
- int op_errno;
- char *op_errstr;
- char *volname;
- char *status;
-};
-typedef struct gf1_cli_replace_brick_rsp gf1_cli_replace_brick_rsp;
-
-struct gf1_cli_reset_vol_req {
- char *volname;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_reset_vol_req gf1_cli_reset_vol_req;
-
-struct gf1_cli_reset_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
-};
-typedef struct gf1_cli_reset_vol_rsp gf1_cli_reset_vol_rsp;
-
-struct gf1_cli_set_vol_req {
- char *volname;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_set_vol_req gf1_cli_set_vol_req;
-
-struct gf1_cli_set_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_set_vol_rsp gf1_cli_set_vol_rsp;
-
-struct gf1_cli_log_filename_req {
- char *volname;
- char *brick;
- char *path;
-};
-typedef struct gf1_cli_log_filename_req gf1_cli_log_filename_req;
-
-struct gf1_cli_log_filename_rsp {
- int op_ret;
- int op_errno;
- char *errstr;
-};
-typedef struct gf1_cli_log_filename_rsp gf1_cli_log_filename_rsp;
-
struct gf1_cli_log_locate_req {
char *volname;
char *brick;
};
typedef struct gf1_cli_log_locate_req gf1_cli_log_locate_req;
-struct gf1_cli_sync_volume_req {
- int flags;
- char *volname;
- char *hostname;
-};
-typedef struct gf1_cli_sync_volume_req gf1_cli_sync_volume_req;
-
struct gf1_cli_log_locate_rsp {
int op_ret;
int op_errno;
@@ -453,26 +239,6 @@ struct gf1_cli_log_locate_rsp {
};
typedef struct gf1_cli_log_locate_rsp gf1_cli_log_locate_rsp;
-struct gf1_cli_log_rotate_req {
- char *volname;
- char *brick;
-};
-typedef struct gf1_cli_log_rotate_req gf1_cli_log_rotate_req;
-
-struct gf1_cli_log_rotate_rsp {
- int op_ret;
- int op_errno;
- char *errstr;
-};
-typedef struct gf1_cli_log_rotate_rsp gf1_cli_log_rotate_rsp;
-
-struct gf1_cli_sync_volume_rsp {
- int op_ret;
- int op_errno;
- char *op_errstr;
-};
-typedef struct gf1_cli_sync_volume_rsp gf1_cli_sync_volume_rsp;
-
struct gf1_cli_fsm_log_req {
char *name;
};
@@ -489,66 +255,6 @@ struct gf1_cli_fsm_log_rsp {
};
typedef struct gf1_cli_fsm_log_rsp gf1_cli_fsm_log_rsp;
-struct gf1_cli_gsync_set_req {
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_gsync_set_req gf1_cli_gsync_set_req;
-
-struct gf1_cli_gsync_set_rsp {
- int op_ret;
- int op_errno;
- char *op_errstr;
- int type;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_gsync_set_rsp gf1_cli_gsync_set_rsp;
-
-struct gf1_cli_stats_volume_req {
- char *volname;
- gf1_cli_stats_op op;
- struct {
- u_int dict_req_len;
- char *dict_req_val;
- } dict_req;
-};
-typedef struct gf1_cli_stats_volume_req gf1_cli_stats_volume_req;
-
-struct gf1_cli_stats_volume_rsp {
- int op_ret;
- int op_errno;
- char *op_errstr;
- struct {
- u_int stats_info_len;
- char *stats_info_val;
- } stats_info;
-};
-typedef struct gf1_cli_stats_volume_rsp gf1_cli_stats_volume_rsp;
-
-struct gf1_cli_quota_req {
- char *volname;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_quota_req gf1_cli_quota_req;
-
-struct gf1_cli_quota_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
- char *limit_list;
- gf_quota_type type;
-};
-typedef struct gf1_cli_quota_rsp gf1_cli_quota_rsp;
-
struct gf1_cli_getwd_req {
int unused;
};
@@ -561,40 +267,6 @@ struct gf1_cli_getwd_rsp {
};
typedef struct gf1_cli_getwd_rsp gf1_cli_getwd_rsp;
-struct gf1_cli_log_level_req {
- char *volname;
- char *xlator;
- char *loglevel;
-};
-typedef struct gf1_cli_log_level_req gf1_cli_log_level_req;
-
-struct gf1_cli_log_level_rsp {
- int op_ret;
- int op_errno;
- char *op_errstr;
-};
-typedef struct gf1_cli_log_level_rsp gf1_cli_log_level_rsp;
-
-struct gf1_cli_status_volume_req {
- char *volname;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_status_volume_req gf1_cli_status_volume_req;
-
-struct gf1_cli_status_volume_rsp {
- int op_ret;
- int op_errno;
- char *op_errstr;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_status_volume_rsp gf1_cli_status_volume_rsp;
-
struct gf1_cli_mount_req {
char *label;
struct {
@@ -623,42 +295,6 @@ struct gf1_cli_umount_rsp {
};
typedef struct gf1_cli_umount_rsp gf1_cli_umount_rsp;
-struct gf1_cli_heal_vol_req {
- char *volname;
-};
-typedef struct gf1_cli_heal_vol_req gf1_cli_heal_vol_req;
-
-struct gf1_cli_heal_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_heal_vol_rsp gf1_cli_heal_vol_rsp;
-
-struct gf1_cli_statedump_vol_req {
- char *volname;
- char *options;
- int option_cnt;
-};
-typedef struct gf1_cli_statedump_vol_req gf1_cli_statedump_vol_req;
-
-struct gf1_cli_statedump_vol_rsp {
- int op_ret;
- int op_errno;
- char *volname;
- char *op_errstr;
- struct {
- u_int dict_len;
- char *dict_val;
- } dict;
-};
-typedef struct gf1_cli_statedump_vol_rsp gf1_cli_statedump_vol_rsp;
-
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
@@ -675,67 +311,24 @@ extern bool_t xdr_gf1_cli_op_flags (XDR *, gf1_cli_op_flags*);
extern bool_t xdr_gf1_cli_gsync_set (XDR *, gf1_cli_gsync_set*);
extern bool_t xdr_gf1_cli_stats_op (XDR *, gf1_cli_stats_op*);
extern bool_t xdr_gf1_cli_top_op (XDR *, gf1_cli_top_op*);
+extern bool_t xdr_gf_cli_req (XDR *, gf_cli_req*);
+extern bool_t xdr_gf_cli_rsp (XDR *, gf_cli_rsp*);
extern bool_t xdr_gf1_cli_probe_req (XDR *, gf1_cli_probe_req*);
extern bool_t xdr_gf1_cli_probe_rsp (XDR *, gf1_cli_probe_rsp*);
extern bool_t xdr_gf1_cli_deprobe_req (XDR *, gf1_cli_deprobe_req*);
extern bool_t xdr_gf1_cli_deprobe_rsp (XDR *, gf1_cli_deprobe_rsp*);
extern bool_t xdr_gf1_cli_peer_list_req (XDR *, gf1_cli_peer_list_req*);
extern bool_t xdr_gf1_cli_peer_list_rsp (XDR *, gf1_cli_peer_list_rsp*);
-extern bool_t xdr_gf1_cli_get_vol_req (XDR *, gf1_cli_get_vol_req*);
-extern bool_t xdr_gf1_cli_get_vol_rsp (XDR *, gf1_cli_get_vol_rsp*);
-extern bool_t xdr_gf1_cli_create_vol_req (XDR *, gf1_cli_create_vol_req*);
-extern bool_t xdr_gf1_cli_create_vol_rsp (XDR *, gf1_cli_create_vol_rsp*);
-extern bool_t xdr_gf1_cli_delete_vol_req (XDR *, gf1_cli_delete_vol_req*);
-extern bool_t xdr_gf1_cli_delete_vol_rsp (XDR *, gf1_cli_delete_vol_rsp*);
-extern bool_t xdr_gf1_cli_start_vol_req (XDR *, gf1_cli_start_vol_req*);
-extern bool_t xdr_gf1_cli_start_vol_rsp (XDR *, gf1_cli_start_vol_rsp*);
-extern bool_t xdr_gf1_cli_stop_vol_req (XDR *, gf1_cli_stop_vol_req*);
-extern bool_t xdr_gf1_cli_stop_vol_rsp (XDR *, gf1_cli_stop_vol_rsp*);
-extern bool_t xdr_gf1_cli_rename_vol_req (XDR *, gf1_cli_rename_vol_req*);
-extern bool_t xdr_gf1_cli_rename_vol_rsp (XDR *, gf1_cli_rename_vol_rsp*);
-extern bool_t xdr_gf1_cli_defrag_vol_req (XDR *, gf1_cli_defrag_vol_req*);
-extern bool_t xdr_gf1_cli_defrag_vol_rsp (XDR *, gf1_cli_defrag_vol_rsp*);
-extern bool_t xdr_gf2_cli_defrag_vol_rsp (XDR *, gf2_cli_defrag_vol_rsp*);
-extern bool_t xdr_gf1_cli_add_brick_req (XDR *, gf1_cli_add_brick_req*);
-extern bool_t xdr_gf1_cli_add_brick_rsp (XDR *, gf1_cli_add_brick_rsp*);
-extern bool_t xdr_gf1_cli_remove_brick_req (XDR *, gf1_cli_remove_brick_req*);
-extern bool_t xdr_gf1_cli_remove_brick_rsp (XDR *, gf1_cli_remove_brick_rsp*);
-extern bool_t xdr_gf1_cli_replace_brick_req (XDR *, gf1_cli_replace_brick_req*);
-extern bool_t xdr_gf1_cli_replace_brick_rsp (XDR *, gf1_cli_replace_brick_rsp*);
-extern bool_t xdr_gf1_cli_reset_vol_req (XDR *, gf1_cli_reset_vol_req*);
-extern bool_t xdr_gf1_cli_reset_vol_rsp (XDR *, gf1_cli_reset_vol_rsp*);
-extern bool_t xdr_gf1_cli_set_vol_req (XDR *, gf1_cli_set_vol_req*);
-extern bool_t xdr_gf1_cli_set_vol_rsp (XDR *, gf1_cli_set_vol_rsp*);
-extern bool_t xdr_gf1_cli_log_filename_req (XDR *, gf1_cli_log_filename_req*);
-extern bool_t xdr_gf1_cli_log_filename_rsp (XDR *, gf1_cli_log_filename_rsp*);
extern bool_t xdr_gf1_cli_log_locate_req (XDR *, gf1_cli_log_locate_req*);
-extern bool_t xdr_gf1_cli_sync_volume_req (XDR *, gf1_cli_sync_volume_req*);
extern bool_t xdr_gf1_cli_log_locate_rsp (XDR *, gf1_cli_log_locate_rsp*);
-extern bool_t xdr_gf1_cli_log_rotate_req (XDR *, gf1_cli_log_rotate_req*);
-extern bool_t xdr_gf1_cli_log_rotate_rsp (XDR *, gf1_cli_log_rotate_rsp*);
-extern bool_t xdr_gf1_cli_sync_volume_rsp (XDR *, gf1_cli_sync_volume_rsp*);
extern bool_t xdr_gf1_cli_fsm_log_req (XDR *, gf1_cli_fsm_log_req*);
extern bool_t xdr_gf1_cli_fsm_log_rsp (XDR *, gf1_cli_fsm_log_rsp*);
-extern bool_t xdr_gf1_cli_gsync_set_req (XDR *, gf1_cli_gsync_set_req*);
-extern bool_t xdr_gf1_cli_gsync_set_rsp (XDR *, gf1_cli_gsync_set_rsp*);
-extern bool_t xdr_gf1_cli_stats_volume_req (XDR *, gf1_cli_stats_volume_req*);
-extern bool_t xdr_gf1_cli_stats_volume_rsp (XDR *, gf1_cli_stats_volume_rsp*);
-extern bool_t xdr_gf1_cli_quota_req (XDR *, gf1_cli_quota_req*);
-extern bool_t xdr_gf1_cli_quota_rsp (XDR *, gf1_cli_quota_rsp*);
extern bool_t xdr_gf1_cli_getwd_req (XDR *, gf1_cli_getwd_req*);
extern bool_t xdr_gf1_cli_getwd_rsp (XDR *, gf1_cli_getwd_rsp*);
-extern bool_t xdr_gf1_cli_log_level_req (XDR *, gf1_cli_log_level_req*);
-extern bool_t xdr_gf1_cli_log_level_rsp (XDR *, gf1_cli_log_level_rsp*);
-extern bool_t xdr_gf1_cli_status_volume_req (XDR *, gf1_cli_status_volume_req*);
-extern bool_t xdr_gf1_cli_status_volume_rsp (XDR *, gf1_cli_status_volume_rsp*);
extern bool_t xdr_gf1_cli_mount_req (XDR *, gf1_cli_mount_req*);
extern bool_t xdr_gf1_cli_mount_rsp (XDR *, gf1_cli_mount_rsp*);
extern bool_t xdr_gf1_cli_umount_req (XDR *, gf1_cli_umount_req*);
extern bool_t xdr_gf1_cli_umount_rsp (XDR *, gf1_cli_umount_rsp*);
-extern bool_t xdr_gf1_cli_heal_vol_req (XDR *, gf1_cli_heal_vol_req*);
-extern bool_t xdr_gf1_cli_heal_vol_rsp (XDR *, gf1_cli_heal_vol_rsp*);
-extern bool_t xdr_gf1_cli_statedump_vol_req (XDR *, gf1_cli_statedump_vol_req*);
-extern bool_t xdr_gf1_cli_statedump_vol_rsp (XDR *, gf1_cli_statedump_vol_rsp*);
#else /* K&R C */
extern bool_t xdr_gf_cli_defrag_type ();
@@ -751,67 +344,24 @@ extern bool_t xdr_gf1_cli_op_flags ();
extern bool_t xdr_gf1_cli_gsync_set ();
extern bool_t xdr_gf1_cli_stats_op ();
extern bool_t xdr_gf1_cli_top_op ();
+extern bool_t xdr_gf_cli_req ();
+extern bool_t xdr_gf_cli_rsp ();
extern bool_t xdr_gf1_cli_probe_req ();
extern bool_t xdr_gf1_cli_probe_rsp ();
extern bool_t xdr_gf1_cli_deprobe_req ();
extern bool_t xdr_gf1_cli_deprobe_rsp ();
extern bool_t xdr_gf1_cli_peer_list_req ();
extern bool_t xdr_gf1_cli_peer_list_rsp ();
-extern bool_t xdr_gf1_cli_get_vol_req ();
-extern bool_t xdr_gf1_cli_get_vol_rsp ();
-extern bool_t xdr_gf1_cli_create_vol_req ();
-extern bool_t xdr_gf1_cli_create_vol_rsp ();
-extern bool_t xdr_gf1_cli_delete_vol_req ();
-extern bool_t xdr_gf1_cli_delete_vol_rsp ();
-extern bool_t xdr_gf1_cli_start_vol_req ();
-extern bool_t xdr_gf1_cli_start_vol_rsp ();
-extern bool_t xdr_gf1_cli_stop_vol_req ();
-extern bool_t xdr_gf1_cli_stop_vol_rsp ();
-extern bool_t xdr_gf1_cli_rename_vol_req ();
-extern bool_t xdr_gf1_cli_rename_vol_rsp ();
-extern bool_t xdr_gf1_cli_defrag_vol_req ();
-extern bool_t xdr_gf1_cli_defrag_vol_rsp ();
-extern bool_t xdr_gf2_cli_defrag_vol_rsp ();
-extern bool_t xdr_gf1_cli_add_brick_req ();
-extern bool_t xdr_gf1_cli_add_brick_rsp ();
-extern bool_t xdr_gf1_cli_remove_brick_req ();
-extern bool_t xdr_gf1_cli_remove_brick_rsp ();
-extern bool_t xdr_gf1_cli_replace_brick_req ();
-extern bool_t xdr_gf1_cli_replace_brick_rsp ();
-extern bool_t xdr_gf1_cli_reset_vol_req ();
-extern bool_t xdr_gf1_cli_reset_vol_rsp ();
-extern bool_t xdr_gf1_cli_set_vol_req ();
-extern bool_t xdr_gf1_cli_set_vol_rsp ();
-extern bool_t xdr_gf1_cli_log_filename_req ();
-extern bool_t xdr_gf1_cli_log_filename_rsp ();
extern bool_t xdr_gf1_cli_log_locate_req ();
-extern bool_t xdr_gf1_cli_sync_volume_req ();
extern bool_t xdr_gf1_cli_log_locate_rsp ();
-extern bool_t xdr_gf1_cli_log_rotate_req ();
-extern bool_t xdr_gf1_cli_log_rotate_rsp ();
-extern bool_t xdr_gf1_cli_sync_volume_rsp ();
extern bool_t xdr_gf1_cli_fsm_log_req ();
extern bool_t xdr_gf1_cli_fsm_log_rsp ();
-extern bool_t xdr_gf1_cli_gsync_set_req ();
-extern bool_t xdr_gf1_cli_gsync_set_rsp ();
-extern bool_t xdr_gf1_cli_stats_volume_req ();
-extern bool_t xdr_gf1_cli_stats_volume_rsp ();
-extern bool_t xdr_gf1_cli_quota_req ();
-extern bool_t xdr_gf1_cli_quota_rsp ();
extern bool_t xdr_gf1_cli_getwd_req ();
extern bool_t xdr_gf1_cli_getwd_rsp ();
-extern bool_t xdr_gf1_cli_log_level_req ();
-extern bool_t xdr_gf1_cli_log_level_rsp ();
-extern bool_t xdr_gf1_cli_status_volume_req ();
-extern bool_t xdr_gf1_cli_status_volume_rsp ();
extern bool_t xdr_gf1_cli_mount_req ();
extern bool_t xdr_gf1_cli_mount_rsp ();
extern bool_t xdr_gf1_cli_umount_req ();
extern bool_t xdr_gf1_cli_umount_rsp ();
-extern bool_t xdr_gf1_cli_heal_vol_req ();
-extern bool_t xdr_gf1_cli_heal_vol_rsp ();
-extern bool_t xdr_gf1_cli_statedump_vol_req ();
-extern bool_t xdr_gf1_cli_statedump_vol_rsp ();
#endif /* K&R C */
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
index 9e5dd80af08..2b4f4499b05 100644
--- a/rpc/xdr/src/cli1-xdr.x
+++ b/rpc/xdr/src/cli1-xdr.x
@@ -103,6 +103,17 @@ enum gf1_cli_top_op {
GF_CLI_TOP_WRITE_PERF
};
+ struct gf_cli_req {
+ opaque dict<>;
+} ;
+
+ struct gf_cli_rsp {
+ int op_ret;
+ int op_errno;
+ string op_errstr<>;
+ opaque dict<>;
+} ;
+
struct gf1_cli_probe_req {
string hostname<>;
int port;
@@ -138,221 +149,17 @@ struct gf1_cli_peer_list_rsp {
opaque friends<>;
} ;
-struct gf1_cli_get_vol_req {
- int flags;
- opaque dict<>;
-} ;
-
-struct gf1_cli_get_vol_rsp {
- int op_ret;
- int op_errno;
- opaque volumes<>;
-} ;
-
- struct gf1_cli_create_vol_req {
- string volname<>;
- gf1_cluster_type type;
- int count;
- opaque bricks<>;
-} ;
-
- struct gf1_cli_create_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
-} ;
-
- struct gf1_cli_delete_vol_req {
- string volname<>;
-} ;
-
- struct gf1_cli_delete_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
-} ;
-
- struct gf1_cli_start_vol_req {
- string volname<>;
- int flags;
-} ;
-
-
- struct gf1_cli_start_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
-} ;
-
- struct gf1_cli_stop_vol_req {
- string volname<>;
- int flags;
-} ;
-
-
- struct gf1_cli_stop_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
-} ;
-
-
- struct gf1_cli_rename_vol_req {
- string old_volname<>;
- string new_volname<>;
-} ;
-
- struct gf1_cli_rename_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
-} ;
-
- struct gf1_cli_defrag_vol_req {
- int cmd;
- string volname<>;
-} ;
-
- struct gf1_cli_defrag_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- unsigned hyper files;
- unsigned hyper size;
- unsigned hyper lookedup_files;
-} ;
-
-
- struct gf2_cli_defrag_vol_rsp {
- int op_ret;
- int op_errno;
- string op_errstr<>;
- string volname<>;
- unsigned hyper files;
- unsigned hyper size;
- unsigned hyper lookedup_files;
-} ;
-
- struct gf1_cli_add_brick_req {
- string volname<>;
- int count;
- opaque bricks<>;
-} ;
-
- struct gf1_cli_add_brick_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
-} ;
-
- struct gf1_cli_remove_brick_req {
- string volname<>;
- int count;
- opaque bricks<>;
-} ;
-
-
- struct gf1_cli_remove_brick_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
-} ;
-
- struct gf1_cli_replace_brick_req {
- string volname<>;
- gf1_cli_replace_op op;
- opaque bricks<>;
-} ;
-
- struct gf1_cli_replace_brick_rsp {
- int op_ret;
- int op_errno;
- string op_errstr<>;
- string volname<>;
- string status<>;
-} ;
-
-struct gf1_cli_reset_vol_req {
- string volname<>;
- opaque dict<>;
-} ;
-
-
- struct gf1_cli_reset_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
-} ;
-
-
-
-struct gf1_cli_set_vol_req {
- string volname<>;
- opaque dict<>;
-} ;
-
-
- struct gf1_cli_set_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
- opaque dict<>;
-} ;
-
-struct gf1_cli_log_filename_req {
- string volname<>;
- string brick<>;
- string path<>;
-};
-
-struct gf1_cli_log_filename_rsp {
- int op_ret;
- int op_errno;
- string errstr<>;
-};
-
struct gf1_cli_log_locate_req {
string volname<>;
string brick<>;
};
-struct gf1_cli_sync_volume_req {
- int flags;
- string volname<>;
- string hostname<>;
-};
-
struct gf1_cli_log_locate_rsp {
int op_ret;
int op_errno;
string path<>;
};
-struct gf1_cli_log_rotate_req {
- string volname<>;
- string brick<>;
-};
-
-struct gf1_cli_log_rotate_rsp {
- int op_ret;
- int op_errno;
- string errstr<>;
-};
-
-struct gf1_cli_sync_volume_rsp {
- int op_ret;
- int op_errno;
- string op_errstr<>;
-};
-
struct gf1_cli_fsm_log_req {
string name<>;
};
@@ -364,45 +171,6 @@ struct gf1_cli_fsm_log_rsp {
opaque fsm_log<>;
};
-struct gf1_cli_gsync_set_req {
- opaque dict<>;
-};
-
-struct gf1_cli_gsync_set_rsp {
- int op_ret;
- int op_errno;
- string op_errstr<>;
- int type;
- opaque dict<>;
-};
-
-struct gf1_cli_stats_volume_req {
- string volname<>;
- gf1_cli_stats_op op;
- opaque dict_req<>;
-};
-
-struct gf1_cli_stats_volume_rsp {
- int op_ret;
- int op_errno;
- string op_errstr<>;
- opaque stats_info<>;
-};
-
-struct gf1_cli_quota_req {
- string volname<>;
- opaque dict<>;
-} ;
-
-struct gf1_cli_quota_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
- string limit_list<>;
- gf_quota_type type;
-};
-
struct gf1_cli_getwd_req {
int unused;
} ;
@@ -413,30 +181,6 @@ struct gf1_cli_getwd_rsp {
string wd<>;
};
-struct gf1_cli_log_level_req {
- string volname<>;
- string xlator<>;
- string loglevel<>;
-};
-
-struct gf1_cli_log_level_rsp {
- int op_ret;
- int op_errno;
- string op_errstr<>;
-};
-
-struct gf1_cli_status_volume_req {
- string volname<>;
- opaque dict<>;
-};
-
-struct gf1_cli_status_volume_rsp {
- int op_ret;
- int op_errno;
- string op_errstr<>;
- opaque dict<>;
-};
-
struct gf1_cli_mount_req {
string label<>;
opaque dict<>;
@@ -457,28 +201,3 @@ struct gf1_cli_umount_rsp {
int op_ret;
int op_errno;
};
-
-struct gf1_cli_heal_vol_req {
- string volname<>;
-} ;
-
-struct gf1_cli_heal_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
- opaque dict<>;
-};
-struct gf1_cli_statedump_vol_req {
- string volname<>;
- string options<>;
- int option_cnt;
-};
-
-struct gf1_cli_statedump_vol_rsp {
- int op_ret;
- int op_errno;
- string volname<>;
- string op_errstr<>;
- opaque dict<>;
-};
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 ();
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index f6ea5aeae3d..3f56636cdf0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -47,7 +47,7 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
{
int32_t ret = 0;
dict_t *dict = NULL;
- gf1_cli_gsync_set_req cli_req = {{0},};
+ gf_cli_req cli_req = {{0},};
glusterd_op_t cli_op = GD_OP_GSYNC_SET;
char *master = NULL;
char *slave = NULL;
@@ -63,7 +63,7 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
priv = THIS->private;
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_gsync_set_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
req->rpc_err = GARBAGE_ARGS;
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index ff00824642e..04d3525ae39 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -817,12 +817,13 @@ int
glusterd_handle_cli_get_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_get_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
+ int32_t flags = 0;
GF_ASSERT (req);
- if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_get_vol_req)) {
+ if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
@@ -847,7 +848,13 @@ glusterd_handle_cli_get_volume (rpcsvc_request_t *req)
}
}
- ret = glusterd_get_volumes (req, dict, cli_req.flags);
+ ret = dict_get_int32 (dict, "flags", &flags);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get flags");
+ goto out;
+ }
+
+ ret = glusterd_get_volumes (req, dict, flags);
out:
if (dict)
@@ -875,13 +882,14 @@ int
glusterd_handle_reset_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_reset_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_RESET_VOLUME;
+ char *volname = NULL;
GF_ASSERT (req);
- if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_set_vol_req)) {
+ if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
@@ -903,15 +911,18 @@ glusterd_handle_reset_volume (rpcsvc_request_t *req)
}
}
- gf_cmd_log ("Volume reset", "volume : %s", cli_req.volname);
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
+ goto out;
+ }
+
+ gf_cmd_log ("Volume reset", "volume : %s", volname);
ret = glusterd_op_begin (req, GD_OP_RESET_VOLUME, dict);
- gf_cmd_log ("Volume reset", " on volume %s %s ", cli_req.volname,
+ gf_cmd_log ("Volume reset", " on volume %s %s ", volname,
((ret == 0)? " SUCCEDED":" FAILED"));
out:
- if (cli_req.volname)
- free (cli_req.volname);//malloced by xdr
-
glusterd_friend_sm ();
glusterd_op_sm ();
if (ret) {
@@ -929,7 +940,7 @@ int
glusterd_handle_set_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_set_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_SET_VOLUME;
char *key = NULL;
@@ -938,7 +949,7 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
GF_ASSERT (req);
- if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_set_vol_req)) {
+ if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
@@ -993,8 +1004,6 @@ glusterd_handle_set_volume (rpcsvc_request_t *req)
gf_cmd_log ("volume set", "volume-name:%s: key:%s, value:%s %s",
volname, key, value, (ret == 0)? "SUCCEDED" : "FAILED" );
out:
- if (cli_req.volname)
- free (cli_req.volname);//malloced by xdr
glusterd_friend_sm ();
glusterd_op_sm ();
@@ -1012,73 +1021,83 @@ int
glusterd_handle_sync_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_sync_volume_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
- gf1_cli_sync_volume_rsp cli_rsp = {0.};
+ gf_cli_rsp cli_rsp = {0.};
char msg[2048] = {0,};
- gf_boolean_t free_hostname = _gf_true;
- gf_boolean_t free_volname = _gf_true;
glusterd_volinfo_t *volinfo = NULL;
+ char *volname = NULL;
+ gf1_cli_sync_volume flags = 0;
+ char *hostname = NULL;
GF_ASSERT (req);
- if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_sync_volume_req)) {
+ if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received volume sync req "
- "for volume %s",
- (cli_req.flags & GF_CLI_SYNC_ALL) ? "all" : cli_req.volname);
- dict = dict_new ();
- if (!dict) {
- gf_log ("", GF_LOG_ERROR, "Can't allocate sync vol dict");
- goto out;
- }
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- if (!glusterd_is_local_addr (cli_req.hostname)) {
- ret = -1;
- snprintf (msg, sizeof (msg), "sync from localhost"
- " not allowed");
- goto out;
+ 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.dict.dict_val;
+ }
}
- ret = dict_set_dynmstr (dict, "hostname", cli_req.hostname);
+ ret = dict_get_str (dict, "hostname", &hostname);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "hostname set failed");
- snprintf (msg, sizeof (msg), "hostname set failed");
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get hostname");
goto out;
- } else {
- free_hostname = _gf_false;
}
- ret = dict_set_int32 (dict, "flags", cli_req.flags);
+ ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "volume flags set failed");
- snprintf (msg, sizeof (msg), "volume flags set failed");
+ ret = dict_get_int32 (dict, "flags", (int32_t*)&flags);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Unable to get volume"
+ "name, or flags");
+ goto out;
+ }
+ }
+
+ gf_log ("glusterd", GF_LOG_INFO, "Received volume sync req "
+ "for volume %s",
+ (flags & GF_CLI_SYNC_ALL) ? "all" : volname);
+
+ if (!glusterd_is_local_addr (hostname)) {
+ ret = -1;
+ snprintf (msg, sizeof (msg), "sync from localhost"
+ " not allowed");
goto out;
}
- if (!cli_req.flags) {
- ret = glusterd_volinfo_find (cli_req.volname, &volinfo);
+ if (!flags) {
+ ret = glusterd_volinfo_find (volname, &volinfo);
if (!ret) {
snprintf (msg, sizeof (msg), "please delete the "
- "volume: %s before sync", cli_req.volname);
+ "volume: %s before sync", volname);
ret = -1;
goto out;
}
- ret = dict_set_dynmstr (dict, "volname", cli_req.volname);
+ 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 {
- free_volname = _gf_false;
}
} else {
- free_volname = _gf_false;
if (glusterd_volume_count_get ()) {
snprintf (msg, sizeof (msg), "please delete all the "
"volumes before full sync");
@@ -1096,11 +1115,7 @@ out:
if (msg[0] == '\0')
snprintf (msg, sizeof (msg), "Operation failed");
glusterd_submit_reply(req, &cli_rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf1_cli_sync_volume_rsp);
- if (free_hostname && cli_req.hostname)
- free (cli_req.hostname);
- if (free_volname && cli_req.volname)
- free (cli_req.volname);
+ (xdrproc_t)xdr_gf_cli_rsp);
if (dict)
dict_unref (dict);
@@ -1686,72 +1701,60 @@ int
glusterd_handle_cli_profile_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_stats_volume_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
- char msg[2048] = {0,};
- gf_boolean_t free_volname = _gf_true;
glusterd_op_t cli_op = GD_OP_PROFILE_VOLUME;
- dict_t *tmp_dict = NULL;
+ char *volname = NULL;
+ int32_t op = 0;
GF_ASSERT (req);
- if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_stats_volume_req)) {
+ if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received volume profile req "
- "for volume %s", cli_req.volname);
- dict = dict_new ();
- if (!dict)
- goto out;
- ret = dict_set_dynmstr (dict, "volname", cli_req.volname);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "volume name set failed");
- snprintf (msg, sizeof (msg), "volume name set failed");
- goto out;
- } else {
- free_volname = _gf_false;
+
+
+ if (cli_req.dict.dict_len > 0) {
+ dict = dict_new();
+ if (!dict)
+ goto out;
+ dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len, &dict);
+
}
- ret = dict_set_int32 (dict, "op", cli_req.op);
+ ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log ("", GF_LOG_ERROR, "op set failed");
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
goto out;
}
- if (cli_req.dict_req.dict_req_len > 0) {
- tmp_dict = dict_new();
- if (!tmp_dict)
- goto out;
- dict_unserialize (cli_req.dict_req.dict_req_val,
- cli_req.dict_req.dict_req_len, &tmp_dict);
-
- dict_copy (tmp_dict, dict);
+ gf_log ("glusterd", GF_LOG_INFO, "Received volume profile req "
+ "for volume %s", volname);
+ ret = dict_get_int32 (dict, "op", &op);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get op");
+ goto out;
}
- gf_cmd_log ("Volume stats", "volume : %s, op: %d", cli_req.volname,
- cli_req.op);
+ gf_cmd_log ("Volume stats", "volume : %s, op: %d", volname, op);
ret = glusterd_op_begin (req, cli_op, dict);
gf_cmd_log ("Volume stats", " on volume %s, op: %d %s ",
- cli_req.volname, cli_req.op,
+ volname, op,
((ret == 0)? " SUCCEDED":" FAILED"));
out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (tmp_dict)
- dict_unref (tmp_dict);
-
if (ret && dict)
dict_unref (dict);
- if (cli_req.dict_req.dict_req_val)
- free (cli_req.dict_req.dict_req_val);
- if (free_volname)
- free (cli_req.volname); // malloced by xdr
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);
if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
@@ -2389,7 +2392,7 @@ glusterd_get_volumes (rpcsvc_request_t *req, dict_t *dict, int32_t flags)
glusterd_volinfo_t *entry = NULL;
int32_t count = 0;
dict_t *volumes = NULL;
- gf1_cli_get_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
char *volname = NULL;
priv = THIS->private;
@@ -2466,8 +2469,8 @@ respond:
ret = dict_set_int32 (volumes, "count", count);
if (ret)
goto out;
- ret = dict_allocate_and_serialize (volumes, &rsp.volumes.volumes_val,
- (size_t *)&rsp.volumes.volumes_len);
+ ret = dict_allocate_and_serialize (volumes, &rsp.dict.dict_val,
+ (size_t *)&rsp.dict.dict_len);
if (ret)
goto out;
@@ -2476,14 +2479,15 @@ respond:
out:
rsp.op_ret = ret;
+ rsp.op_errstr = "";
ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf1_cli_peer_list_rsp);
+ (xdrproc_t)xdr_gf_cli_rsp);
if (volumes)
dict_unref (volumes);
- if (rsp.volumes.volumes_val)
- GF_FREE (rsp.volumes.volumes_val);
+ if (rsp.dict.dict_val)
+ GF_FREE (rsp.dict.dict_val);
return ret;
}
@@ -2491,29 +2495,43 @@ int
glusterd_handle_status_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_status_volume_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_STATUS_VOLUME;
+ char *volname = 0;
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_status_volume_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received status volume req "
- "for volume %s", cli_req.volname);
+ if (cli_req.dict.dict_len > 0) {
+ dict = dict_new();
+ if (!dict)
+ goto out;
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len, &dict);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to "
+ "unserialize buffer");
+ goto out;
+ }
- dict = dict_new ();
- if (!dict)
- goto out;
+ }
- ret = dict_set_dynmstr (dict, "volname", cli_req.volname);
- if (ret)
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
goto out;
+ }
+
+ gf_log ("glusterd", GF_LOG_INFO, "Received status volume req "
+ "for volume %s", volname);
+
ret = glusterd_op_begin (req, GD_OP_STATUS_VOLUME, dict);
@@ -2527,6 +2545,8 @@ out:
if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
index 9d1c9782671..b032e902d8b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c
@@ -37,36 +37,44 @@ int
glusterd_handle_log_filename (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_log_filename_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_LOG_FILENAME;
+ char *volname = NULL;
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_log_filename_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received log filename req "
- "for volume %s", cli_req.volname);
- dict = dict_new ();
- if (!dict)
- goto out;
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- ret = dict_set_dynmstr (dict, "volname", cli_req.volname);
- if (ret)
- goto out;
- ret = dict_set_dynmstr (dict, "brick", cli_req.brick);
- if (ret)
- goto out;
- ret = dict_set_dynmstr (dict, "path", cli_req.path);
- if (ret)
+ 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;
+ }
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
goto out;
+ }
+ gf_log ("glusterd", GF_LOG_INFO, "Received log filename req "
+ "for volume %s", volname);
ret = glusterd_op_begin (req, GD_OP_LOG_FILENAME, dict);
out:
@@ -79,7 +87,8 @@ out:
if (ret)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
-
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);
return ret;
}
@@ -190,38 +199,57 @@ glusterd_handle_log_level (rpcsvc_request_t *req)
{
int32_t ret = -1;
dict_t *dict = NULL;
- gf1_cli_log_level_req cli_req = {0,};
- glusterd_op_t cli_op = GD_OP_LOG_LEVEL;
+ gf_cli_req cli_req = {{0,}};
+ glusterd_op_t cli_op = GD_OP_LOG_LEVEL;
+ char *loglevel = NULL;
+ char *xlator = NULL;
+ char *volname = NULL;
GF_ASSERT(req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_log_level_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
gf_log ("glusterd", GF_LOG_ERROR, "Failed to decode rpc message");
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_DEBUG, "Got log level request for: Volume [%s]"
- " Xlator [%s] LogLevel [\"%s\"]", cli_req.volname, cli_req.xlator, cli_req.loglevel);
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- dict = dict_new ();
- if (!dict)
- goto out;
+ 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;
+ }
+ }
- ret = dict_set_dynmstr (dict, "volname", cli_req.volname);
- if (ret)
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
goto out;
+ }
- ret = dict_set_dynmstr (dict, "xlator", cli_req.xlator);
- if (ret)
+ ret = dict_get_str (dict, "xlator", &xlator);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get xlator");
goto out;
+ }
- ret = dict_set_dynmstr (dict, "loglevel", cli_req.loglevel);
- if (ret)
+ ret = dict_get_str (dict, "loglevel", &loglevel);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get loglevel");
goto out;
+ }
+ gf_log ("glusterd", GF_LOG_DEBUG, "Got log level request for: Volume [%s]"
+ " Xlator [%s] LogLevel [\"%s\"]", volname, xlator, loglevel);
ret = glusterd_op_begin (req, cli_op, dict);
out:
@@ -235,6 +263,9 @@ glusterd_handle_log_level (rpcsvc_request_t *req)
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req, NULL,
"Operation failed");
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);
+
return ret;
}
@@ -242,33 +273,43 @@ int
glusterd_handle_log_rotate (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_log_rotate_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_LOG_ROTATE;
+ char *volname = NULL;
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_log_rotate_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received log rotate req "
- "for volume %s", cli_req.volname);
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- dict = dict_new ();
- if (!dict)
- goto out;
+ 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;
+ }
+ }
- ret = dict_set_dynmstr (dict, "volname", cli_req.volname);
- if (ret)
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
goto out;
+ }
- ret = dict_set_dynmstr (dict, "brick", cli_req.brick);
- if (ret)
- goto out;
+ gf_log ("glusterd", GF_LOG_INFO, "Received log rotate req "
+ "for volume %s", volname);
ret = dict_set_uint64 (dict, "rotate-key", (uint64_t)time (NULL));
if (ret)
@@ -287,6 +328,8 @@ out:
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index aebaef974ad..881cf66b49d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -38,7 +38,7 @@ int
glusterd_handle_quota (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_quota_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_QUOTA;
char operation[256] = {0, };
@@ -48,7 +48,7 @@ glusterd_handle_quota (rpcsvc_request_t *req)
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_quota_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
@@ -116,8 +116,6 @@ out:
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
NULL, "operation failed");
}
- if (cli_req.volname)
- free (cli_req.volname); //malloced by xdr
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index f848d73fddf..a50180ea5f6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -466,29 +466,53 @@ out:
int
glusterd_defrag_status_get (glusterd_volinfo_t *volinfo,
- gf1_cli_defrag_vol_rsp *rsp)
+ dict_t *rsp)
{
- if (!volinfo)
+ uint64_t files = 0;
+ uint64_t size = 0;
+ uint64_t lookedup_files = 0;
+ int ret = -1;
+
+ if (!volinfo || !rsp)
goto out;
if (volinfo->defrag) {
LOCK (&volinfo->defrag->lock);
{
- rsp->files = volinfo->defrag->total_files;
- rsp->size = volinfo->defrag->total_data;
- rsp->lookedup_files = volinfo->defrag->num_files_lookedup;
+ files = volinfo->defrag->total_files;
+ size = volinfo->defrag->total_data;
+ lookedup_files = volinfo->defrag->num_files_lookedup;
}
UNLOCK (&volinfo->defrag->lock);
} else {
- rsp->files = volinfo->rebalance_files;
- rsp->size = volinfo->rebalance_data;
- rsp->lookedup_files = volinfo->lookedup_files;
+ files = volinfo->rebalance_files;
+ size = volinfo->rebalance_data;
+ lookedup_files = volinfo->lookedup_files;
+ }
+
+ ret = dict_set_uint64 (rsp, "files", files);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set dict");
+ goto out;
}
- rsp->op_errno = volinfo->defrag_status;
- rsp->op_ret = 0;
+ ret = dict_set_uint64 (rsp, "size", size);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set dict");
+ goto out;
+ }
+ ret = dict_set_uint64 (rsp, "lookedup-files", lookedup_files);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set dict");
+ goto out;
+ }
+
+ return volinfo->defrag_status;
out:
- return 0;
+ return ret;
}
void
@@ -683,51 +707,106 @@ int
glusterd_handle_defrag_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_defrag_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
glusterd_conf_t *priv = NULL;
char cmd_str[4096] = {0,};
glusterd_volinfo_t *volinfo = NULL;
- gf1_cli_defrag_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
char msg[2048] = {0};
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ gf_cli_defrag_type cmd = 0;
+ uint64_t files = 0;
+ uint64_t size = 0;
GF_ASSERT (req);
priv = THIS->private;
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_defrag_vol_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- glusterd_rebalance_cmd_attempted_log (cli_req.cmd, cli_req.volname);
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
+
+ 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;
+ }
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to get volname");
+ goto out;
+ }
+
+ ret = dict_get_int32 (dict, "rebalance-command", (int32_t*)&cmd);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to get command");
+ goto out;
+ }
+
+ glusterd_rebalance_cmd_attempted_log (cmd, volname);
- rsp.volname = cli_req.volname;
rsp.op_ret = -1;
- ret = glusterd_rebalance_cmd_validate (cli_req.cmd, cli_req.volname,
+ ret = glusterd_rebalance_cmd_validate (cmd, volname,
&volinfo, msg, sizeof (msg));
if (ret)
goto out;
- switch (cli_req.cmd) {
+ switch (cmd) {
case GF_DEFRAG_CMD_START:
case GF_DEFRAG_CMD_START_LAYOUT_FIX:
case GF_DEFRAG_CMD_START_MIGRATE_DATA:
case GF_DEFRAG_CMD_START_MIGRATE_DATA_FORCE:
{
ret = glusterd_handle_defrag_start (volinfo, msg, sizeof (msg),
- cli_req.cmd, NULL);
+ cmd, NULL);
rsp.op_ret = ret;
break;
}
case GF_DEFRAG_CMD_STOP:
- ret = glusterd_defrag_stop (volinfo, &rsp.files, &rsp.size,
+ ret = glusterd_defrag_stop (volinfo, &files, &size,
msg, sizeof (msg));
+ ret = dict_set_uint64 (dict, "files", files);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set files argument");
+ rsp.op_ret = ret;
+ goto out;
+ }
+
+ ret = dict_set_uint64 (dict, "size", size);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to set size argument");
+ rsp.op_ret = ret;
+ goto out;
+ }
+
rsp.op_ret = ret;
break;
case GF_DEFRAG_CMD_STATUS:
- ret = glusterd_defrag_status_get (volinfo, &rsp);
+ ret = glusterd_defrag_status_get (volinfo, dict);
+ if (ret != -1) {
+ rsp.op_errno = ret;
+ rsp.op_ret = 0;
+ ret = 0;
+ }
+
break;
default:
break;
@@ -735,17 +814,31 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req)
if (ret)
gf_log("glusterd", GF_LOG_DEBUG, "command: %s failed",cmd_str);
- if (cli_req.cmd != GF_DEFRAG_CMD_STATUS) {
+ if (cmd != GF_DEFRAG_CMD_STATUS) {
gf_cmd_log ("volume rebalance"," on volname: %s %d %s",
- cli_req.volname,
- cli_req.cmd, ((ret)?"FAILED":"SUCCESS"));
+ volname,
+ cmd, ((ret)?"FAILED":"SUCCESS"));
}
out:
+ ret = dict_allocate_and_serialize (dict,
+ &rsp.dict.dict_val,
+ (size_t *) &rsp.dict.dict_len);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to serialize the data");
+
+ goto out;
+ }
+
ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
- (xdrproc_t)xdr_gf1_cli_defrag_vol_rsp);
- if (cli_req.volname)
- free (cli_req.volname);//malloced by xdr
+ (xdrproc_t)xdr_gf_cli_rsp);
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);//malloced by xdr
+
+ if (dict)
+ dict_unref (dict);
+
return 0;
}
@@ -754,45 +847,57 @@ int
glusterd_handle_defrag_volume_v2 (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_defrag_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
glusterd_conf_t *priv = NULL;
dict_t *dict = NULL;
char *volname = NULL;
+ gf_cli_defrag_type cmd = 0;
GF_ASSERT (req);
priv = THIS->private;
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_defrag_vol_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
+
+ 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;
+ }
+ }
- glusterd_rebalance_cmd_attempted_log (cli_req.cmd, cli_req.volname);
-
- dict = dict_new ();
- if (!dict)
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to get volname");
goto out;
+ }
- volname = gf_strdup (cli_req.volname);
- if (!volname)
+ ret = dict_get_int32 (dict, "rebalance-command", (int32_t*)&cmd);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to get command");
goto out;
+ }
- /* let 'volname' be freed in dict_destroy */
- ret = dict_set_dynstr (dict, "volname", volname);
- if (ret)
- goto out;
+ glusterd_rebalance_cmd_attempted_log (cmd, volname);
ret = dict_set_static_bin (dict, "node-uuid", priv->uuid, 16);
if (ret)
goto out;
- ret = dict_set_int32 (dict, "rebalance-command", cli_req.cmd);
- if (ret)
- goto out;
-
ret = glusterd_op_begin (req, GD_OP_REBALANCE, dict);
out:
@@ -807,8 +912,8 @@ out:
NULL, "operation failed");
}
- if (cli_req.volname)
- free (cli_req.volname);//malloced by xdr
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);//malloced by xdr
return 0;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
index 7ae59a833d5..640fd07e0e1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
+++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c
@@ -39,18 +39,19 @@ int
glusterd_handle_replace_brick (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_replace_brick_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
char *src_brick = NULL;
char *dst_brick = NULL;
int32_t op = 0;
char operation[256];
glusterd_op_t cli_op = GD_OP_REPLACE_BRICK;
+ char *volname = NULL;
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_replace_brick_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
@@ -58,23 +59,27 @@ glusterd_handle_replace_brick (rpcsvc_request_t *req)
gf_log ("glusterd", GF_LOG_INFO, "Received replace 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, "could not get volname");
+ goto out;
+ }
+
ret = dict_get_int32 (dict, "operation", &op);
if (ret) {
gf_log ("", GF_LOG_DEBUG,
@@ -120,18 +125,18 @@ glusterd_handle_replace_brick (rpcsvc_request_t *req)
gf_log ("glusterd", GF_LOG_INFO, "Received replace brick %s request", operation);
gf_cmd_log ("Volume replace-brick","volname: %s src_brick:%s"
- " dst_brick:%s op:%s",cli_req.volname, src_brick, dst_brick
+ " dst_brick:%s op:%s", volname, src_brick, dst_brick
,operation);
ret = glusterd_op_begin (req, GD_OP_REPLACE_BRICK, dict);
- gf_cmd_log ("Volume replace-brick","on volname: %s %s", cli_req.volname,
+ gf_cmd_log ("Volume replace-brick","on volname: %s %s", volname,
(ret) ? "FAILED" : "SUCCESS");
out:
if (ret && dict)
dict_unref (dict);
- if (cli_req.volname)
- free (cli_req.volname);//malloced by xdr
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);//malloced by xdr
glusterd_friend_sm ();
glusterd_op_sm ();
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
index ea7a2620fae..92be21f9f0f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c
@@ -58,6 +58,9 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
char *free_ptr = NULL;
glusterd_conf_t *conf = NULL;
xdrproc_t xdrproc = NULL;
+ char *errstr = NULL;
+ int32_t status = 0;
+ int32_t is_ctx_dict = 0;
GF_ASSERT (THIS);
@@ -65,425 +68,115 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
GF_ASSERT (conf);
- switch (op) {
- case GD_OP_CREATE_VOLUME:
- {
- gf1_cli_create_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t)xdr_gf1_cli_create_vol_rsp;
- break;
- }
-
- case GD_OP_START_VOLUME:
- {
- gf1_cli_start_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_start_vol_rsp;
- break;
- }
-
- case GD_OP_STOP_VOLUME:
- {
- gf1_cli_stop_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_stop_vol_rsp;
- break;
- }
-
- case GD_OP_DELETE_VOLUME:
- {
- gf1_cli_delete_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_delete_vol_rsp;
- break;
- }
-
- case GD_OP_DEFRAG_VOLUME:
- {
- gf1_cli_defrag_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- //rsp.volname = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_defrag_vol_rsp;
- break;
- }
-
- case GD_OP_ADD_BRICK:
- {
- gf1_cli_add_brick_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_add_brick_rsp;
- break;
- }
+ ctx = op_ctx;
+ switch (op) {
case GD_OP_REMOVE_BRICK:
{
- gf1_cli_remove_brick_rsp rsp = {0,};
- ctx = op_ctx;
- if (ctx &&
- dict_get_str (ctx, "errstr", &rsp.op_errstr))
- rsp.op_errstr = "";
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_remove_brick_rsp;
- break;
+ if (ctx)
+ ret = dict_get_str (ctx, "errstr", &errstr);
+ is_ctx_dict = 1;
+ goto done;
}
-
- case GD_OP_REPLACE_BRICK:
+ case GD_OP_RESET_VOLUME:
{
- gf1_cli_replace_brick_rsp rsp = {0,};
- ctx = op_ctx;
- if (ctx &&
- dict_get_str (ctx, "status-reply", &rsp.status))
- rsp.status = "";
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- rsp.volname = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_replace_brick_rsp;
- break;
+ if (op_ret && !op_errstr)
+ errstr = "Error while resetting options";
+ goto done;
}
-
- case GD_OP_SET_VOLUME:
+ case GD_OP_REBALANCE:
{
- gf1_cli_set_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- ctx = op_ctx;
-
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
if (ctx) {
- ret = dict_allocate_and_serialize (ctx,
- &rsp.dict.dict_val,
- (size_t*)&rsp.dict.dict_len);
- if (ret == 0)
- free_ptr = rsp.dict.dict_val;
+ ret = dict_get_int32 (ctx, "status", &status);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_TRACE,
+ "failed to get status");
+ }
+ is_ctx_dict = 1;
}
-
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_set_vol_rsp;
- break;
- }
-
- case GD_OP_RESET_VOLUME:
- {
- gf_log ("", GF_LOG_DEBUG, "Return value to CLI");
- gf1_cli_reset_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = 1;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "Error while resetting options";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_reset_vol_rsp;
- break;
- }
-
- case GD_OP_LOG_FILENAME:
- {
- gf1_cli_log_filename_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- if (op_errstr)
- rsp.errstr = op_errstr;
- else
- rsp.errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_log_filename_rsp;
- break;
- }
- case GD_OP_LOG_ROTATE:
- {
- gf1_cli_log_rotate_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- if (op_errstr)
- rsp.errstr = op_errstr;
- else
- rsp.errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_log_rotate_rsp;
- break;
- }
- case GD_OP_SYNC_VOLUME:
- {
- gf1_cli_sync_volume_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_sync_volume_rsp;
- break;
+ goto done;
}
case GD_OP_GSYNC_SET:
{
- int type = 0;
- char *str = NULL;
- gf1_cli_gsync_set_rsp rsp = {0,};
-
- ctx = op_ctx;
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.op_errstr = "";
- if (ctx) {
- ret = dict_get_str (ctx, "errstr", &str);
- if (ret == 0)
- rsp.op_errstr = str;
- ret = dict_get_int32 (ctx, "type", &type);
- if (ret == 0)
- rsp.type = type;
+ if (ctx) {
+ ret = dict_get_str (ctx, "errstr", &errstr);
ret = dict_set_str (ctx, "glusterd_workdir", conf->workdir);
/* swallow error here, that will be re-triggered in cli */
- ret = dict_allocate_and_serialize (ctx,
- &rsp.dict.dict_val,
- (size_t*)&rsp.dict.dict_len);
+ is_ctx_dict = 1;
+ goto done;
+ }
- if (ret == 0)
- free_ptr = rsp.dict.dict_val;
-
- }
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_gsync_set_rsp;
- break;
- }
- case GD_OP_RENAME_VOLUME:
- case GD_OP_START_BRICK:
- case GD_OP_STOP_BRICK:
- case GD_OP_LOG_LOCATE:
- {
- gf_log ("", GF_LOG_DEBUG, "not supported op %d", op);
- break;
- }
- case GD_OP_PROFILE_VOLUME:
- {
- gf1_cli_stats_volume_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- ctx = op_ctx;
- if (ctx)
- dict_allocate_and_serialize (ctx,
- &rsp.stats_info.stats_info_val,
- (size_t*)&rsp.stats_info.stats_info_len);
- free_ptr = rsp.stats_info.stats_info_val;
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_stats_volume_rsp;
- break;
}
-
case GD_OP_QUOTA:
{
- int32_t type;
- char *str = NULL;
- char *errstr = NULL;
- gf1_cli_quota_rsp rsp = {0,};
-
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
-
- ctx = op_ctx;
-
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else {
+ if (ctx && !op_errstr) {
ret = dict_get_str (ctx, "errstr", &errstr);
- if (ret == 0)
- rsp.op_errstr = errstr;
- else
- rsp.op_errstr = "";
- }
-
- rsp.limit_list = "";
-
- if (op_ret == 0 && ctx) {
- ret = dict_get_str (ctx, "volname", &str);
- if (ret == 0)
- rsp.volname = str;
-
- ret = dict_get_int32 (ctx, "type", &type);
- if (ret == 0)
- rsp.type = type;
- else
- rsp.type = 0;
-
- if (type == GF_QUOTA_OPTION_TYPE_LIST) {
- ret = dict_get_str (ctx,"limit_list", &str);
-
- if (ret == 0)
- rsp.limit_list = str;
- }
}
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_quota_rsp;
- break;
+ is_ctx_dict = 1;
+ goto done;
}
-
- case GD_OP_LOG_LEVEL:
+ case GD_OP_REPLACE_BRICK:
+ case GD_OP_STATUS_VOLUME:
+ case GD_OP_SET_VOLUME:
+ case GD_OP_PROFILE_VOLUME:
{
- gf1_cli_log_level_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
-
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_log_level_rsp;
- break;
+ is_ctx_dict = 1;
}
+ case GD_OP_CREATE_VOLUME:
+ case GD_OP_START_VOLUME:
+ case GD_OP_STOP_VOLUME:
+ case GD_OP_DELETE_VOLUME:
+ case GD_OP_DEFRAG_VOLUME:
+ case GD_OP_ADD_BRICK:
+ case GD_OP_LOG_FILENAME:
+ case GD_OP_LOG_ROTATE:
+ case GD_OP_SYNC_VOLUME:
+ case GD_OP_LOG_LEVEL:
+ case GD_OP_HEAL_VOLUME:
+ case GD_OP_STATEDUMP_VOLUME:
-
- case GD_OP_STATUS_VOLUME:
+done:
{
- gf1_cli_status_volume_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- if (op_errstr)
+ rsp.op_errno = errno;
+ if (errstr)
+ rsp.op_errstr = errstr;
+ else if (op_errstr)
rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- ctx = op_ctx;
- dict_allocate_and_serialize (ctx,
- &rsp.dict.dict_val,
- (size_t*)&rsp.dict.dict_len);
- free_ptr = rsp.dict.dict_val;
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_status_volume_rsp;
- break;
- }
- case GD_OP_REBALANCE:
- {
- gf2_cli_defrag_vol_rsp rsp = {0,};
- int32_t status = 0;
- ctx = op_ctx;
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
+ if (!rsp.op_errstr)
rsp.op_errstr = "";
- if (ctx) {
- ret = dict_get_uint64 (ctx, "files", &rsp.files);
- if (ret) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "failed to get the file count");
- }
- ret = dict_get_uint64 (ctx, "size", &rsp.size);
- if (ret) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "failed to get the size of migration");
- }
- ret = dict_get_uint64 (ctx, "lookups", &rsp.lookedup_files);
- if (ret) {
- gf_log (THIS->name, GF_LOG_DEBUG,
- "failed to get lookuped file count");
- }
-
- ret = dict_get_int32 (ctx, "status", &status);
- if (ret) {
- gf_log (THIS->name, GF_LOG_TRACE,
- "failed to get status");
+ if (ctx && is_ctx_dict) {
+ ret = dict_allocate_and_serialize (ctx, &rsp.dict.dict_val,
+ (size_t*)&rsp.dict.dict_len);
+ if (ret < 0 ) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to "
+ "serialize buffer");
+ break;
}
+ free_ptr = rsp.dict.dict_val;
}
/* needed by 'rebalance status' */
if (status)
rsp.op_errno = status;
cli_rsp = &rsp;
- xdrproc = (xdrproc_t)xdr_gf2_cli_defrag_vol_rsp;
+ xdrproc = (xdrproc_t) xdr_gf_cli_rsp;
break;
}
- case GD_OP_HEAL_VOLUME:
- {
- gf1_cli_heal_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = op_errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_heal_vol_rsp;
- break;
- }
- case GD_OP_STATEDUMP_VOLUME:
+ case GD_OP_RENAME_VOLUME:
+ case GD_OP_START_BRICK:
+ case GD_OP_STOP_BRICK:
+ case GD_OP_LOG_LOCATE:
{
- gf1_cli_statedump_vol_rsp rsp = {0,};
- rsp.op_ret = op_ret;
- rsp.op_errno = errno;
- rsp.volname = "";
- if (op_errstr)
- rsp.op_errstr = op_errstr;
- else
- rsp.op_errstr = "";
- cli_rsp = &rsp;
- xdrproc = (xdrproc_t) xdr_gf1_cli_statedump_vol_rsp;
+ gf_log ("", GF_LOG_DEBUG, "not supported op %d", op);
break;
}
+
case GD_OP_NONE:
case GD_OP_MAX:
{
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index b1686b32162..6c3da47ea24 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -39,7 +39,7 @@ int
glusterd_handle_create_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_create_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
char *brick = NULL;
@@ -51,13 +51,14 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
char *brick_list = NULL;
void *cli_rsp = NULL;
char err_str[2048] = {0,};
- gf1_cli_create_vol_rsp rsp = {0,};
+ gf_cli_rsp rsp = {0,};
xlator_t *this = NULL;
char *free_ptr = NULL;
char *trans_type = NULL;
uuid_t volume_id = {0,};
glusterd_brickinfo_t *tmpbrkinfo = NULL;
glusterd_volinfo_t tmpvolinfo = {{0},};
+ int32_t type = 0;
GF_ASSERT (req);
@@ -68,7 +69,7 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
ret = -1;
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_create_vol_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");
@@ -77,12 +78,12 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
gf_log ("glusterd", GF_LOG_INFO, "Received create volume 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,
@@ -92,7 +93,7 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
"the buffer");
goto out;
} else {
- dict->extra_stdfree = cli_req.bricks.bricks_val;
+ dict->extra_stdfree = cli_req.dict.dict_val;
}
}
@@ -120,6 +121,14 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
goto out;
}
+ ret = dict_get_int32 (dict, "type", &type);
+ /*if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get type");
+ snprintf (err_str, sizeof (err_str), "Unable to get volume "
+ "type");
+ goto out;
+ }*/
+
ret = dict_get_str (dict, "transport", &trans_type);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get transport-type");
@@ -152,9 +161,8 @@ glusterd_handle_create_volume (rpcsvc_request_t *req)
}
gf_cmd_log ("Volume create", "on volname: %s type:%s count:%d bricks:%s",
- cli_req.volname, ((cli_req.type == 0)? "DEFAULT":
- ((cli_req.type == 1)? "STRIPE":"REPLICATE")), cli_req.count,
- bricks);
+ volname, ((type == 0)? "DEFAULT":
+ ((type == 1)? "STRIPE":"REPLICATE")), brick_count, bricks);
while ( i < brick_count) {
@@ -198,13 +206,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_create_vol_rsp);
+ (xdrproc_t)xdr_gf_cli_rsp);
ret = 0; //Client response sent, prevent second response
}
@@ -215,8 +222,6 @@ out:
glusterd_volume_brickinfos_delete (&tmpvolinfo);
if (brickinfo)
glusterd_brickinfo_delete (brickinfo);
- if (cli_req.volname)
- free (cli_req.volname); // its a malloced by xdr
glusterd_friend_sm ();
glusterd_op_sm ();
@@ -228,7 +233,7 @@ int
glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_start_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
char *dup_volname = NULL;
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_START_VOLUME;
@@ -236,41 +241,45 @@ glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_start_vol_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received start vol req"
- "for volume %s", cli_req.volname);
-
- dict = dict_new ();
-
- if (!dict)
- goto out;
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- dup_volname = gf_strdup (cli_req.volname);
- if (!dup_volname)
- goto out;
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
- ret = dict_set_dynstr (dict, "volname", dup_volname);
- if (ret)
+ ret = dict_get_str (dict, "volname", &dup_volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "dict get failed");
goto out;
+ }
- ret = dict_set_int32 (dict, "flags", cli_req.flags);
- if (ret)
- goto out;
+ gf_log ("glusterd", GF_LOG_INFO, "Received start vol req"
+ "for volume %s", dup_volname);
ret = glusterd_op_begin (req, GD_OP_START_VOLUME, dict);
- gf_cmd_log ("volume start","on volname: %s %s", cli_req.volname,
+ gf_cmd_log ("volume start","on volname: %s %s", dup_volname,
((ret == 0) ? "SUCCESS": "FAILED"));
out:
if (ret && dict)
dict_unref (dict);
- 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 ();
@@ -287,7 +296,7 @@ int
glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_stop_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
char *dup_volname = NULL;
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_STOP_VOLUME;
@@ -295,39 +304,43 @@ glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_stop_vol_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- gf_log ("glusterd", GF_LOG_INFO, "Received stop vol req"
- "for volume %s", cli_req.volname);
-
- dict = dict_new ();
-
- if (!dict)
- goto out;
+ 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;
+ }
+ }
- dup_volname = gf_strdup (cli_req.volname);
- if (!dup_volname)
- goto out;
+ ret = dict_get_str (dict, "volname", &dup_volname);
- ret = dict_set_dynstr (dict, "volname", dup_volname);
- if (ret)
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
goto out;
+ }
- ret = dict_set_int32 (dict, "flags", cli_req.flags);
- if (ret)
- goto out;
+ gf_log ("glusterd", GF_LOG_INFO, "Received stop vol req"
+ "for volume %s", dup_volname);
ret = glusterd_op_begin (req, GD_OP_STOP_VOLUME, dict);
- gf_cmd_log ("Volume stop","on volname: %s %s", cli_req.volname,
+ gf_cmd_log ("Volume stop","on volname: %s %s", dup_volname,
((ret)?"FAILED":"SUCCESS"));
out:
- 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 ();
@@ -346,37 +359,65 @@ int
glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_delete_vol_req cli_req = {0,};
+ gf_cli_req cli_req = {{0,}};
glusterd_op_delete_volume_ctx_t *ctx = NULL;
glusterd_op_t cli_op = GD_OP_DELETE_VOLUME;
+ char *volname = NULL;
+ dict_t *dict = NULL;
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_delete_vol_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_cmd_log ("Volume delete","on volname: %s attempted", cli_req.volname);
+
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
+
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to get volname");
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ gf_cmd_log ("Volume delete","on volname: %s attempted", volname);
gf_log ("glusterd", GF_LOG_INFO, "Received delete vol req"
- "for volume %s", cli_req.volname);
+ "for volume %s", volname);
ctx = GF_CALLOC (1, sizeof (*ctx), gf_gld_mt_delete_volume_ctx_t);
if (!ctx)
goto out;
- strncpy (ctx->volume_name, cli_req.volname, GD_VOLUME_NAME_MAX);
+ strncpy (ctx->volume_name, volname, GD_VOLUME_NAME_MAX);
ret = glusterd_op_begin (req, GD_OP_DELETE_VOLUME, ctx);
- gf_cmd_log ("Volume delete", "on volname: %s %s", cli_req.volname,
+ gf_cmd_log ("Volume delete", "on volname: %s %s", volname,
((ret) ? "FAILED" : "SUCCESS"));
out:
- 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
+ if (dict)
+ dict_unref (dict);
glusterd_friend_sm ();
glusterd_op_sm ();
@@ -396,46 +437,53 @@ int
glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_heal_vol_req cli_req = {0,};
- char *dup_volname = NULL;
+ gf_cli_req cli_req = {{0,}};
dict_t *dict = NULL;
glusterd_op_t cli_op = GD_OP_HEAL_VOLUME;
+ char *volname = NULL;
GF_ASSERT (req);
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_heal_vol_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
//failed to decode msg;
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received heal vol req"
- "for volume %s", cli_req.volname);
-
- dict = dict_new ();
-
- if (!dict)
- goto out;
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- dup_volname = gf_strdup (cli_req.volname);
- if (!dup_volname)
- goto out;
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
- ret = dict_set_dynstr (dict, "volname", dup_volname);
- if (ret)
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
goto out;
+ }
+ gf_log ("glusterd", GF_LOG_INFO, "Received heal vol req"
+ "for volume %s", volname);
ret = glusterd_op_begin (req, GD_OP_HEAL_VOLUME, dict);
- gf_cmd_log ("volume heal","on volname: %s %s", cli_req.volname,
+ gf_cmd_log ("volume heal","on volname: %s %s", volname,
((ret == 0) ? "SUCCESS": "FAILED"));
out:
if (ret && dict)
dict_unref (dict);
- 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 ();
@@ -451,56 +499,66 @@ int
glusterd_handle_cli_statedump_volume (rpcsvc_request_t *req)
{
int32_t ret = -1;
- gf1_cli_statedump_vol_req cli_req = {0,};
- char *dup_volname = NULL;
- char *dup_options = NULL;
+ gf_cli_req cli_req = {{0,}};
+ char *volname = NULL;
+ char *options = NULL;
dict_t *dict = NULL;
+ int32_t option_cnt = 0;
GF_ASSERT (req);
ret = -1;
if (!xdr_to_generic (req->msg[0], &cli_req,
- (xdrproc_t)xdr_gf1_cli_statedump_vol_req)) {
+ (xdrproc_t)xdr_gf_cli_req)) {
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Recieved statedump request for "
- "volume %s with options %s", cli_req.volname, cli_req.options);
- dict = dict_new ();
+ if (cli_req.dict.dict_len) {
+ /* Unserialize the dictionary */
+ dict = dict_new ();
- if (!dict)
+ ret = dict_unserialize (cli_req.dict.dict_val,
+ cli_req.dict.dict_len,
+ &dict);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to "
+ "unserialize req-buffer to dictionary");
+ goto out;
+ }
+ }
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
goto out;
+ }
- dup_volname = gf_strdup (cli_req.volname);
- if (!dup_volname)
- goto out;
- ret = dict_set_dynstr (dict, "volname", dup_volname);
- if (ret)
+ ret = dict_get_str (dict, "options", &options);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get options");
goto out;
+ }
- dup_options = gf_strdup(cli_req.options);
- if (!dup_volname)
- goto out;
- ret = dict_set_dynstr (dict, "options", dup_options);
- if (ret)
+ ret = dict_get_int32 (dict, "option_cnt", &option_cnt);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "failed to get option cnt");
goto out;
+ }
- ret = dict_set_int32 (dict, "option_cnt", cli_req.option_cnt);
- if (ret)
- goto out;
+
+ gf_log ("glusterd", GF_LOG_INFO, "Recieved statedump request for "
+ "volume %s with options %s", volname, options);
ret = glusterd_op_begin (req, GD_OP_STATEDUMP_VOLUME, dict);
- gf_cmd_log ("statedump", "on volume %s %s", cli_req.volname,
+ gf_cmd_log ("statedump", "on volume %s %s", volname,
((0 == ret) ? "SUCCEEDED" : "FAILED"));
out:
if (ret && dict)
dict_unref (dict);
- if (cli_req.volname)
- free (cli_req.volname);
- if (cli_req.options)
- free (cli_req.options);
+ if (cli_req.dict.dict_val)
+ free (cli_req.dict.dict_val);
glusterd_friend_sm ();
glusterd_op_sm();