From 8c833f1ecab9af3762f4e332126399e61fae090c Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Wed, 13 Apr 2011 23:30:22 +0000 Subject: mgmt/glusterd: fail the volume stop opeeration if Gsync sessions are active. Signed-off-by: Kaushik BV Signed-off-by: Anand Avati BUG: 2751 (Volme stop must not be proceeded if gsync sessions are active for the volume) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2751 --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index ad95e340c..b1ace26da 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -110,6 +110,9 @@ typedef struct glusterd_quota_child_info { static int glusterd_restart_brick_servers (glusterd_volinfo_t *); +static int +glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag); + char* glusterd_op_sm_state_name_get (int state) @@ -495,6 +498,7 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) char *volname = NULL; int flags = 0; gf_boolean_t exists = _gf_false; + gf_boolean_t is_run = _gf_false; glusterd_volinfo_t *volinfo = NULL; char msg[2048] = {0}; @@ -530,6 +534,23 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) ret = -1; goto out; } + ret = glusterd_check_gsync_running (volinfo, &is_run); + if (ret && (is_run == _gf_false)) + gf_log ("", GF_LOG_WARNING, "Unable to get the status" + " of active gsync session"); + if (is_run) { + gf_log ("", GF_LOG_WARNING, "Gsync sessions active" + "for the volume %s ", volname); + snprintf (msg, sizeof(msg), "Gsync sessions are active " + "for the volume '%s'.\nUse 'volume gsync " + "status' command for more info. Use 'force'" + "option to ignore and stop stop the volume", + volname); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; + } + } @@ -2327,6 +2348,21 @@ out: return ret; } +static int +glusterd_check_gsync_running (glusterd_volinfo_t *volinfo, gf_boolean_t *flag) +{ + + GF_ASSERT (volinfo); + GF_ASSERT (flag); + + if (volinfo->gsync_slaves->count) + *flag = _gf_true; + else + *flag = _gf_false; + + return 0; +} + static int glusterd_op_verify_gsync_running (glusterd_volinfo_t *volinfo, char *master, char *slave, -- cgit