summaryrefslogtreecommitdiffstats
path: root/glusterfsd/src
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2014-02-06 13:04:32 +0530
committerVijay Bellur <vbellur@redhat.com>2014-04-29 09:37:08 -0700
commit16e71bf8b76eb421e30f5fe239601ba85710c983 (patch)
tree0e92da2563ea2f370314855469201b39ca7782b0 /glusterfsd/src
parent29af4da4b552442e487a898d0b3172a78da0c663 (diff)
glusterd: Add a barrier brick-op
This patch introduces a new 'barrier' brick-op which will be used to activate/deactivate the barriering on the bricks. This includes barriering in the barrier xlator and in the changelog xlator. All the required code has been including a bricks select function, a payload builder and a brick-op handler. Change-Id: I91d9d77f691c2e89823f7dc4e84900ec40dc4dd2 BUG: 1060002 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/6943 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 'glusterfsd/src')
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index c42228a047a..b1f00691c8c 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -1205,6 +1205,116 @@ out:
return ret;
}
+
+int
+glusterfs_handle_barrier (rpcsvc_request_t *req)
+{
+ int ret = -1;
+ gd1_mgmt_brick_op_req brick_req = {0,};
+ gd1_mgmt_brick_op_rsp brick_rsp = {0,};
+ glusterfs_ctx_t *ctx = NULL;
+ glusterfs_graph_t *active = NULL;
+ xlator_t *any = NULL;
+ xlator_t *xlator = NULL;
+ xlator_t *old_THIS = NULL;
+ dict_t *dict = NULL;
+ char name[1024] = {0,};
+
+ GF_ASSERT (req);
+
+ ret = xdr_to_generic(req->msg[0], &brick_req,
+ (xdrproc_t)xdr_gd1_mgmt_brick_op_req);
+ if (ret < 0) {
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ ctx = glusterfsd_ctx;
+ GF_ASSERT (ctx);
+ active = ctx->active;
+ any = active->first;
+
+ dict = dict_new();
+ if (!dict) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_unserialize(brick_req.input.input_val,
+ brick_req.input.input_len, &dict);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Failed to unserialize "
+ "request dictionary");
+ goto out;
+ }
+
+ brick_rsp.op_ret = 0;
+ brick_rsp.op_errstr = ""; // initing to prevent serilaztion failures
+ old_THIS = THIS;
+
+ /* Send barrier request to the barrier xlator */
+ snprintf (name, sizeof (name), "%s-barrier", brick_req.name);
+ xlator = xlator_search_by_name(any, name);
+ if (!xlator) {
+ ret = -1;
+ gf_log (THIS->name, GF_LOG_ERROR, "%s xlator is not loaded",
+ name);
+ goto out;
+ }
+
+ THIS = xlator;
+ // TODO: Extend this to accept return of errnos
+ ret = xlator->notify (xlator, GF_EVENT_TRANSLATOR_OP, dict);
+ if (ret) {
+ brick_rsp.op_ret = ret;
+ brick_rsp.op_errstr = gf_strdup ("Failed to reconfigure "
+ "barrier.");
+ goto submit_reply;
+ }
+
+ /* Reset THIS so that we have it correct in case of an error below
+ */
+ THIS = old_THIS;
+
+ /* Send barrier request to changelog as well */
+ /* Commenting out the below code till the changelog changes are merged
+
+ memset (name, 0, sizeof (name));
+ snprintf (name, sizeof (name), "%s-changelog", brick_req.name);
+ xlator = xlator_search_by_name(any, name);
+ if (!xlator) {
+ ret = -1;
+ gf_log (THIS->name, GF_LOG_ERROR, "%s xlator is not loaded",
+ name);
+ goto out;
+ }
+
+ THIS = xlator;
+ ret = xlator->reconfigure (xlator, dict);
+
+
+ if (ret) {
+ brick_rsp.op_ret = ret;
+ brick_rsp.op_errstr = gf_strdup ("Failed to reconfigure "
+ "changelog.");
+ goto submit_reply;
+ }
+ */
+submit_reply:
+ THIS = old_THIS;
+
+ ret = glusterfs_submit_reply (req, &brick_rsp, NULL, 0, NULL,
+ (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp);
+
+out:
+ if (dict)
+ dict_unref (dict);
+ free (brick_req.input.input_val);
+
+ gf_log (THIS->name, GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
int
glusterfs_handle_rpc_msg (rpcsvc_request_t *req)
{
@@ -1270,6 +1380,7 @@ rpcsvc_actor_t glusterfs_actors[] = {
[GLUSTERD_NODE_PROFILE] = {"NFS PROFILE", GLUSTERD_NODE_PROFILE, glusterfs_handle_nfs_profile, NULL, 0, DRC_NA},
[GLUSTERD_NODE_STATUS] = {"NFS STATUS", GLUSTERD_NODE_STATUS, glusterfs_handle_node_status, NULL, 0, DRC_NA},
[GLUSTERD_VOLUME_BARRIER_OP] = {"VOLUME BARRIER OP", GLUSTERD_VOLUME_BARRIER_OP, glusterfs_handle_volume_barrier_op, NULL, 0, DRC_NA},
+ [GLUSTERD_BRICK_BARRIER] = {"BARRIER", GLUSTERD_BRICK_BARRIER, glusterfs_handle_barrier, NULL, 0, DRC_NA},
};
struct rpcsvc_program glusterfs_mop_prog = {