diff options
author | Amar Tumballi <amar@gluster.com> | 2011-09-07 12:46:30 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-09-09 02:20:23 -0700 |
commit | 85a2f0ec5021d53f34fe1630028f413835abd31e (patch) | |
tree | 88408f05e2cde7d7768a714eeed15685c498b391 /xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | |
parent | 77eb7bdfd02f2ba61847fb9c35e9e19e3da4fcc4 (diff) |
glusterd rebalance: make co-operate with all other 'op'
that way, we can share the rebalance state with other peers
and can prevent confusion/conflicts when multiple rebalances
are done by different peers.
Change-Id: I24159e69332644718df7314f6f1da7fce9ff740e
BUG: 2112
Reviewed-on: http://review.gluster.com/343
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-rpc-ops.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index 06cbdd7935d..aa493bd76ef 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -409,6 +409,51 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, 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 + 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"); + } + } + /* needed by 'rebalance status' */ + if (status) + rsp.op_errno = status; + + cli_rsp = &rsp; + xdrproc = (xdrproc_t)xdr_gf2_cli_defrag_vol_rsp; + break; + } case GD_OP_NONE: case GD_OP_MAX: { @@ -1257,6 +1302,66 @@ out: return ret; } +int +glusterd_volume_rebalance_use_rsp_dict (dict_t *rsp_dict) +{ + int ret = 0; + dict_t *ctx_dict = NULL; + glusterd_op_t op = GD_OP_NONE; + uint64_t value = 0; + int32_t value32 = 0; + + GF_ASSERT (rsp_dict); + + op = glusterd_op_get_op (); + GF_ASSERT (GD_OP_REBALANCE == op); + + ctx_dict = glusterd_op_get_ctx (op); + + if (!ctx_dict) + goto out; + + ret = dict_get_uint64 (rsp_dict, "files", &value); + if (!ret) { + ret = dict_set_uint64 (ctx_dict, "files", value); + if (ret) { + gf_log (THIS->name, GF_LOG_DEBUG, + "failed to set the file count"); + } + } + + ret = dict_get_uint64 (rsp_dict, "size", &value); + if (!ret) { + ret = dict_set_uint64 (ctx_dict, "size", value); + if (ret) { + gf_log (THIS->name, GF_LOG_DEBUG, + "failed to set the size of migration"); + } + } + + ret = dict_get_uint64 (rsp_dict, "lookups", &value); + if (!ret) { + ret = dict_set_uint64 (ctx_dict, "lookups", value); + if (ret) { + gf_log (THIS->name, GF_LOG_DEBUG, + "failed to set lookuped file count"); + } + } + + ret = dict_get_int32 (rsp_dict, "status", &value32); + if (!ret) { + ret = dict_set_int32 (ctx_dict, "status", value32); + if (ret) { + gf_log (THIS->name, GF_LOG_DEBUG, + "failed to set status"); + } + } + +out: + return ret; +} + + int32_t glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) @@ -1372,6 +1477,12 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, ret = glusterd_volume_status_use_rsp_dict (dict); if (ret) goto out; + + case GD_OP_REBALANCE: + ret = glusterd_volume_rebalance_use_rsp_dict (dict); + if (ret) + goto out; + break; default: |