summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-handler.c
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2014-02-11 10:07:24 +0530
committerVijay Bellur <vbellur@redhat.com>2014-04-29 09:37:32 -0700
commit5e4a5a4c27f120102d4c2e3c7d558a20d838cf24 (patch)
tree9819acc18296b122a06dd3a53a16d20f80b86f81 /xlators/mgmt/glusterd/src/glusterd-handler.c
parent16e71bf8b76eb421e30f5fe239601ba85710c983 (diff)
cli: Add a cli command to enable/disable barrier
This patch adds a new 'gluster volume barrier <VOLNAME> {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 <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/6958 Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-handler.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c63
1 files changed, 63 insertions, 0 deletions
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
@@ -3948,6 +3948,68 @@ out:
}
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)
{
glusterd_volinfo_t *volinfo = NULL;
@@ -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 = {