From 8618abaaf07a96c0384db9bd1e7dbbe663f4f24c Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Tue, 6 Jan 2015 20:26:39 +0530 Subject: glusterd/geo-rep: Allow replace/remove brick if geo-rep is stopped. Replace brick: If geo-replication was configured on a volume, replace brick used to fail. This patch allows replace brick to go through if all geo-rep sessions corresponding to that volume is stopped. Remove brick: There was no check for geo-replication for remove brick. Enforce 'remove brick commit' to fail if geo-rep session corresponding to volume is running. Allow 'remove brick commit' only if all of the geo-rep sessions corresponding to that volume is stopped. Code is re-organized for better readability. Change-Id: I02282c2764d8b81e319489c977847e6e437511a4 BUG: 1179638 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/9402 Tested-by: Gluster Build System Reviewed-by: Aravinda VK Reviewed-by: ajeet jha Reviewed-by: Avra Sengupta Reviewed-by: Krishnan Parthasarathi Tested-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 65 ++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-geo-rep.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index c53f027def1..31dd5a481d4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -17,6 +17,7 @@ #include "xdr-generic.h" #include "glusterd.h" #include "glusterd-op-sm.h" +#include "glusterd-geo-rep.h" #include "glusterd-store.h" #include "glusterd-utils.h" #include "glusterd-volgen.h" @@ -1327,8 +1328,9 @@ out: return ret; } -int -glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag) +void +glusterd_check_geo_rep_configured (glusterd_volinfo_t *volinfo, + gf_boolean_t *flag) { GF_ASSERT (volinfo); @@ -1339,7 +1341,7 @@ glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag) else *flag = _gf_false; - return 0; + return; } /* @@ -1497,6 +1499,63 @@ out: return ret; } +/* glusterd_check_geo_rep_running: + * Checks if any geo-rep session is running for the volume. + * + * RETURN VALUE: + * Sets param.active to true if any geo-rep session is active. + * This function sets op_errstr during some error and when any geo-rep + * session is active. It is caller's responsibility to free op_errstr + * in above cases. + */ + +int +glusterd_check_geo_rep_running (gsync_status_param_t *param, char **op_errstr) +{ + char msg[2048] = {0,}; + gf_boolean_t enabled = _gf_false; + int ret = 0; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); + GF_ASSERT (param); + GF_ASSERT (param->volinfo); + GF_ASSERT (op_errstr); + + glusterd_check_geo_rep_configured (param->volinfo, &enabled); + + if (enabled) { + ret = dict_foreach (param->volinfo->gsync_slaves, + _get_slave_status, param); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "_get_slave_satus failed"); + snprintf (msg, sizeof(msg), GEOREP" Unable to" + " get the status of active "GEOREP"" + " session for the volume '%s'.\n" + " Please check the log file for" + " more info.", param->volinfo->volname); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; + } + + if (param->is_active) { + snprintf (msg, sizeof(msg), GEOREP" sessions" + " are active for the volume %s.\nStop" + " "GEOREP " sessions involved in this" + " volume. Use 'volume "GEOREP + " status' command for more info.", + param->volinfo->volname); + *op_errstr = gf_strdup (msg); + goto out; + } + } + out: + return ret; +} + static int glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo, char *slave, char *conf_path, -- cgit