From 12f1fab930dc0f6f103bae03fab981409ed31b4e Mon Sep 17 00:00:00 2001 From: Sachin Pandit Date: Wed, 30 Apr 2014 00:41:56 +0530 Subject: glusterd/snapshot : Barrier code integration with snapshot codebase. As we have new barrier translator in place, we are making use of that during snapshot phase. During snapshot create (pre-commit), we enable the barrier feature and after the commit we disable it. Change-Id: I94212b1c06b0d9b12255ee98313e2d8549b34b17 BUG: 1061685 Signed-off-by: Sachin Pandit Reviewed-on: http://review.gluster.org/7561 Reviewed-by: Kaushal M Reviewed-by: Atin Mukherjee Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-mgmt.c | 88 ++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 6 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index 1ae07370612..95b2de8818f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -19,6 +19,8 @@ #include "glusterd-locks.h" #include "glusterd-mgmt.h" #include "glusterd-op-sm.h" +#include "glusterd-volgen.h" +#include "glusterd-store.h" extern struct rpc_clnt_program gd_mgmt_v3_prog; @@ -1686,6 +1688,68 @@ out: return 0; } +int32_t +glusterd_set_barrier_value (dict_t *dict, char *option) +{ + int32_t ret = -1; + xlator_t *this = NULL; + glusterd_volinfo_t *vol = NULL; + char *volname = NULL; + + this = THIS; + GF_ASSERT (this); + + GF_ASSERT (dict); + GF_ASSERT (option); + + /* TODO : Change this when we support multiple volume. + * As of now only snapshot of single volume is supported, + * Hence volname1 is directly fetched + */ + ret = dict_get_str (dict, "volname1", &volname); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Volname not present in " + "dict"); + goto out; + } + + ret = glusterd_volinfo_find (volname, &vol); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Volume %s not found ", + volname); + goto out; + } + + ret = dict_set_dynstr_with_alloc (dict, "barrier", option); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to set barrier op " + "in request dictionary"); + goto out; + } + + ret = dict_set_dynstr_with_alloc (vol->dict, "features.barrier", + option); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to set barrier op " + "in volume option dict"); + goto out; + } + + gd_update_volume_op_versions (vol); + + ret = glusterd_create_volfiles (vol); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to create volfiles"); + goto out; + } + + ret = glusterd_store_volinfo (vol, GLUSTERD_VOLINFO_VER_AC_INCREMENT); + +out: + gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); + return ret; +} + int32_t glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, dict_t *dict) @@ -1776,10 +1840,16 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, goto out; } - /* BRICK OP PHASE for initiating barrier*/ - ret = dict_set_int32 (req_dict, "barrier", 1); - if (ret) + /* Set the operation type as pre, so that differentiation can be + * made whether the brickop is sent during pre-commit or post-commit + */ + ret = dict_set_dynstr_with_alloc (req_dict, "operation-type", "pre"); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to set " + "operation-type in dictionary"); goto out; + } + ret = glusterd_mgmt_v3_brick_op (conf, op, req_dict, &op_errstr, npeers); if (ret) { @@ -1821,10 +1891,16 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, success = _gf_true; unbarrier: - /* BRICK OP PHASE for removing the barrier*/ - ret = dict_set_int32 (req_dict, "barrier", 0); - if (ret) + /* Set the operation type as post, so that differentiation can be + * made whether the brickop is sent during pre-commit or post-commit + */ + ret = dict_set_dynstr_with_alloc (req_dict, "operation-type", "post"); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Failed to set " + "operation-type in dictionary"); goto out; + } + ret = glusterd_mgmt_v3_brick_op (conf, op, req_dict, &op_errstr, npeers); -- cgit