From acdeed002d30209e0a058c2df0346d4f16c08994 Mon Sep 17 00:00:00 2001 From: Pavan Sondur Date: Fri, 6 Aug 2010 05:31:45 +0000 Subject: add pump xlator and changes for replace-brick Signed-off-by: Pavan Vilas Sondur Signed-off-by: Anand V. Avati BUG: 1235 (Bug for all pump/migrate commits) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1235 --- xlators/mgmt/glusterd/src/glusterd-handler.c | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-handler.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 9aa4801e99b..a8b334c3dd9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -847,6 +847,44 @@ out: return ret; } +int +glusterd_handle_replace_brick (rpcsvc_request_t *req) +{ + int32_t ret = -1; + gf1_cli_replace_brick_req cli_req = {0,}; + dict_t *dict = NULL; + + GF_ASSERT (req); + + if (!gf_xdr_to_cli_replace_brick_req (req->msg[0], &cli_req)) { + //failed to decode msg; + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + gf_log ("glusterd", GF_LOG_NORMAL, "Received replace brick req"); + + if (cli_req.bricks.bricks_len) { + /* Unserialize the dictionary */ + dict = dict_new (); + + ret = dict_unserialize (cli_req.bricks.bricks_val, + cli_req.bricks.bricks_len, + &dict); + if (ret < 0) { + gf_log ("glusterd", GF_LOG_ERROR, + "failed to " + "unserialize req-buffer to dictionary"); + goto out; + } + } + + ret = glusterd_replace_brick (req, dict); + +out: + return ret; +} + int glusterd_handle_remove_brick (rpcsvc_request_t *req) { @@ -1656,6 +1694,23 @@ glusterd_add_brick (rpcsvc_request_t *req, dict_t *dict) return ret; } +int32_t +glusterd_replace_brick (rpcsvc_request_t *req, dict_t *dict) +{ + int32_t ret = -1; + + GF_ASSERT (req); + GF_ASSERT (dict); + + glusterd_op_set_op (GD_OP_REPLACE_BRICK); + + glusterd_op_set_ctx (GD_OP_REPLACE_BRICK, dict); + + ret = glusterd_op_txn_begin (); + + return ret; +} + int32_t glusterd_remove_brick (rpcsvc_request_t *req, dict_t *dict) { -- cgit