summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2012-11-05 21:42:22 +0530
committerVijay Bellur <vbellur@redhat.com>2012-12-03 00:11:02 -0800
commit2fd342a0c21d761d73bfee782717accbce819f24 (patch)
tree981acf4e2fe8f993b0bd520b7dba782ebd87b0de /libglusterfs
parent07c3801808db787e6c0cf0b2bf60a7ab62bc38b7 (diff)
cluster/afr: Provide option to disable readdir failover
In a replica pair unlike files, directories may not have their content in same order, so readdir for same (offset, size) may not give same entries on both the sobvolumes of replica pair. Switching over from one subvolume to another may not be a good idea sometimes. It may lead to duplicate entries or fewer entries or both. This patch provides a way to disable readdir-failover so that applications like rebalance can retry if they want to. Change-Id: I2b23eb224a2e84016a561362932613ac824c11a0 BUG: 859387 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/4159 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs')
0 files changed, 0 insertions, 0 deletions
s='ctx'> 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)) {