diff options
author | Pavan Sondur <pavan@gluster.com> | 2010-09-10 07:32:29 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-10 06:14:02 -0700 |
commit | 6858155d8b0681f9caea5295a2de63252ff9631c (patch) | |
tree | 73b98f8c318cfa4a22c3b71960a4004a1c81bd2a /xlators/mgmt/glusterd/src/glusterd-handler.c | |
parent | 5bec5e4fd6b0cae5e7a5e4d0a72090f4d613b94e (diff) |
mgmt/glusterd: add a dict to glusterd commit response.
Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1582 (replace-brick data missing added brick)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1582
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handler.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 6b5b01c77..86e0ab5a3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -2008,24 +2008,90 @@ glusterd_op_stage_send_resp (rpcsvc_request_t *req, return ret; } +static int +glusterd_fill_rb_commit_rsp (dict_t *rsp_dict) +{ + dict_t *dict = NULL; + int32_t port_no = 0; + int ret = 0; + + dict = glusterd_op_get_ctx (GD_OP_REPLACE_BRICK); + if (!dict) { + gf_log ("", GF_LOG_ERROR, + "Operation Context is not present"); + ret = 0; + goto out; + } + + ret = dict_get_int32 (dict, "src-brick-port", &port_no); + if (ret) { + gf_log ("", GF_LOG_DEBUG, + "Could not get src-brick-port => this must " + "be a non-source glusterd process"); + ret = 0; + goto out; + } + + gf_log ("", GF_LOG_DEBUG, + "This is the source glusterd => fill the src port"); + + ret = dict_set_int32 (rsp_dict, "src-brick-port", port_no); + if (ret) { + gf_log ("", GF_LOG_DEBUG, + "Could not set commit rsp dict"); + goto out; + } + +out: + return ret; +} + int glusterd_op_commit_send_resp (rpcsvc_request_t *req, int32_t op, int32_t status) { - gd1_mgmt_commit_op_rsp rsp = {{0}, }; - int ret = -1; + dict_t *rsp_dict = NULL; + gd1_mgmt_commit_op_rsp rsp = {{0}, }; + int ret = -1; GF_ASSERT (req); rsp.op_ret = status; glusterd_get_uuid (&rsp.uuid); rsp.op = op; + rsp_dict = dict_new (); + if (!rsp_dict) { + gf_log ("", GF_LOG_DEBUG, + "Out of memory"); + ret = -1; + goto out; + } + + if (op == GD_OP_REPLACE_BRICK) { + ret = glusterd_fill_rb_commit_rsp (rsp_dict); + if (ret) + goto out; + } + + ret = dict_allocate_and_serialize (rsp_dict, + &rsp.dict.dict_val, + (size_t *)&rsp.dict.dict_len); + if (ret < 0) { + gf_log ("", GF_LOG_DEBUG, + "failed to get serialized length of dict"); + goto out; + } + + ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, gd_xdr_serialize_mgmt_commit_op_rsp); gf_log ("glusterd", GF_LOG_NORMAL, "Responded to commit, ret: %d", ret); +out: + if (rsp_dict) + dict_unref (rsp_dict); return ret; } |