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 <spandit@redhat.com> Reviewed-on: http://review.gluster.org/7561 Reviewed-by: Kaushal M <kaushal@redhat.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
parent
9934033030
commit
12f1fab930
@ -19,6 +19,8 @@
|
|||||||
#include "glusterd-locks.h"
|
#include "glusterd-locks.h"
|
||||||
#include "glusterd-mgmt.h"
|
#include "glusterd-mgmt.h"
|
||||||
#include "glusterd-op-sm.h"
|
#include "glusterd-op-sm.h"
|
||||||
|
#include "glusterd-volgen.h"
|
||||||
|
#include "glusterd-store.h"
|
||||||
|
|
||||||
extern struct rpc_clnt_program gd_mgmt_v3_prog;
|
extern struct rpc_clnt_program gd_mgmt_v3_prog;
|
||||||
|
|
||||||
@ -1686,6 +1688,68 @@ out:
|
|||||||
return 0;
|
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
|
int32_t
|
||||||
glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
|
glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
|
||||||
dict_t *dict)
|
dict_t *dict)
|
||||||
@ -1776,10 +1840,16 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* BRICK OP PHASE for initiating barrier*/
|
/* Set the operation type as pre, so that differentiation can be
|
||||||
ret = dict_set_int32 (req_dict, "barrier", 1);
|
* made whether the brickop is sent during pre-commit or post-commit
|
||||||
if (ret)
|
*/
|
||||||
|
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;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = glusterd_mgmt_v3_brick_op (conf, op, req_dict,
|
ret = glusterd_mgmt_v3_brick_op (conf, op, req_dict,
|
||||||
&op_errstr, npeers);
|
&op_errstr, npeers);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -1821,10 +1891,16 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
|
|||||||
|
|
||||||
success = _gf_true;
|
success = _gf_true;
|
||||||
unbarrier:
|
unbarrier:
|
||||||
/* BRICK OP PHASE for removing the barrier*/
|
/* Set the operation type as post, so that differentiation can be
|
||||||
ret = dict_set_int32 (req_dict, "barrier", 0);
|
* made whether the brickop is sent during pre-commit or post-commit
|
||||||
if (ret)
|
*/
|
||||||
|
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;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = glusterd_mgmt_v3_brick_op (conf, op, req_dict,
|
ret = glusterd_mgmt_v3_brick_op (conf, op, req_dict,
|
||||||
&op_errstr, npeers);
|
&op_errstr, npeers);
|
||||||
|
|
||||||
|
@ -42,4 +42,6 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
|
|||||||
int
|
int
|
||||||
glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src);
|
glusterd_snap_pre_validate_use_rsp_dict (dict_t *dst, dict_t *src);
|
||||||
|
|
||||||
|
int32_t
|
||||||
|
glusterd_set_barrier_value (dict_t *dict, char *option);
|
||||||
#endif /* _GLUSTERD_MGMT_H_ */
|
#endif /* _GLUSTERD_MGMT_H_ */
|
||||||
|
@ -523,12 +523,11 @@ glusterd_brick_op_build_payload (glusterd_op_t op, glusterd_brickinfo_t *brickin
|
|||||||
if (!brick_req)
|
if (!brick_req)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
brick_req->op = GLUSTERD_VOLUME_BARRIER_OP;
|
brick_req->op = GLUSTERD_BRICK_BARRIER;
|
||||||
ret = dict_get_str (dict, "volname", &volname);
|
ret = dict_get_str (dict, "volname", &volname);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
snprintf (name, 1024, "%s-server",volname);
|
brick_req->name = gf_strdup (volname);
|
||||||
brick_req->name = gf_strdup (name);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case GD_OP_BARRIER:
|
case GD_OP_BARRIER:
|
||||||
|
@ -5043,6 +5043,7 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|||||||
char *volname = NULL;
|
char *volname = NULL;
|
||||||
int32_t snap_command = 0;
|
int32_t snap_command = 0;
|
||||||
xlator_t *this = NULL;
|
xlator_t *this = NULL;
|
||||||
|
char *op_type = NULL;
|
||||||
|
|
||||||
this = THIS;
|
this = THIS;
|
||||||
|
|
||||||
@ -5059,6 +5060,44 @@ glusterd_snapshot_brickop (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|||||||
|
|
||||||
switch (snap_command) {
|
switch (snap_command) {
|
||||||
case GF_SNAP_OPTION_TYPE_CREATE:
|
case GF_SNAP_OPTION_TYPE_CREATE:
|
||||||
|
|
||||||
|
/* op_type with tell us whether its pre-commit operation
|
||||||
|
* or post-commit
|
||||||
|
*/
|
||||||
|
ret = dict_get_str (dict, "operation-type", &op_type);
|
||||||
|
if (ret) {
|
||||||
|
gf_log (this->name, GF_LOG_ERROR, "Failed to fetch "
|
||||||
|
"operation type");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp (op_type, "pre") == 0) {
|
||||||
|
/* BRICK OP PHASE for enabling barrier, Enable barrier
|
||||||
|
* if its a pre-commit operation
|
||||||
|
*/
|
||||||
|
ret = glusterd_set_barrier_value (dict, "enable");
|
||||||
|
if (ret) {
|
||||||
|
gf_log (this->name, GF_LOG_ERROR, "Failed to "
|
||||||
|
"set barrier value as enable in dict");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
} else if (strcmp (op_type, "post") == 0) {
|
||||||
|
/* BRICK OP PHASE for disabling barrier, Disable barrier
|
||||||
|
* if its a post-commit operation
|
||||||
|
*/
|
||||||
|
ret = glusterd_set_barrier_value (dict, "disable");
|
||||||
|
if (ret) {
|
||||||
|
gf_log (this->name, GF_LOG_ERROR, "Failed to "
|
||||||
|
"set barrier value as disable in "
|
||||||
|
"dict");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = -1;
|
||||||
|
gf_log (this->name, GF_LOG_ERROR, "Invalid op_type");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = dict_get_int64 (dict, "volcount", &vol_count);
|
ret = dict_get_int64 (dict, "volcount", &vol_count);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user