From 5e4a5a4c27f120102d4c2e3c7d558a20d838cf24 Mon Sep 17 00:00:00 2001 From: Kaushal M Date: Tue, 11 Feb 2014 10:07:24 +0530 Subject: cli: Add a cli command to enable/disable barrier This patch adds a new 'gluster volume barrier {enable|disable}' cli command. This helps in testing the brick op code path when testing the barrier xlator. This patch can be reverted later if not required for end users. Change-Id: Icd86a2d13e7f276dda1ecbb2593d60638ece7dcd BUG: 1060002 Signed-off-by: Kaushal M Reviewed-on: http://review.gluster.org/6958 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-handler.c | 63 ++++++++++++++++++++++++++++ 1 file changed, 63 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 b8202b233cd..c840803fbf0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -3947,6 +3947,68 @@ out: return ret; } +static int +__glusterd_handle_barrier (rpcsvc_request_t *req) +{ + int ret = -1; + xlator_t *this = NULL; + gf_cli_req cli_req = {{0,}}; + dict_t *dict = NULL; + char *volname = NULL; + + GF_ASSERT (req); + this = THIS; + GF_ASSERT(this); + + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + if (!cli_req.dict.dict_len) { + ret = -1; + goto out; + } + + dict = dict_new(); + if (!dict) { + ret = -1; + 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 " + "request dictionary."); + goto out; + } + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Volname not present in " + "dict"); + goto out; + } + gf_log (this->name, GF_LOG_INFO, "Recieved barrier volume request for " + "volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_BARRIER, dict); + +out: + if (ret) { + ret = glusterd_op_send_cli_response (GD_OP_BARRIER, ret, 0, req, + dict, "Operation failed"); + } + free (cli_req.dict.dict_val); + return ret; +} + +int +glusterd_handle_barrier (rpcsvc_request_t *req) +{ + return glusterd_big_locked_handler (req, __glusterd_handle_barrier); +} static int get_brickinfo_from_brickid (char *brickid, glusterd_brickinfo_t **brickinfo) { @@ -4356,6 +4418,7 @@ rpcsvc_actor_t gd_svc_cli_actors[] = { [GLUSTER_CLI_COPY_FILE] = {"COPY_FILE", GLUSTER_CLI_COPY_FILE, glusterd_handle_copy_file, NULL, 0, DRC_NA}, [GLUSTER_CLI_SYS_EXEC] = {"SYS_EXEC", GLUSTER_CLI_SYS_EXEC, glusterd_handle_sys_exec, NULL, 0, DRC_NA}, [GLUSTER_CLI_SNAP] = {"SNAP", GLUSTER_CLI_SNAP, glusterd_handle_snapshot, NULL, 0, DRC_NA}, + [GLUSTER_CLI_BARRIER_VOLUME] = {"BARRIER_VOLUME", GLUSTER_CLI_BARRIER_VOLUME, glusterd_handle_barrier, NULL, 0, DRC_NA}, }; struct rpcsvc_program gd_svc_cli_prog = { -- cgit