From c7985fe0d384846fb8974ab75eda7995bb354d79 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 27 Sep 2011 15:52:31 +0530 Subject: glusterd : 'volume stop' to check if other ops are in progress * handles the case of 'rebalance' in progress * inturn it will also handle the case of decommissioning in progress * also now checks if a replace-brick is in progress Change-Id: I0266483089515d16fe8167afe06a07696328a8e3 BUG: 3358 Reviewed-on: http://review.gluster.com/518 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi --- xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 72 +++++++++++++++---------- 1 file changed, 43 insertions(+), 29 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index 21e797386..a335a98cd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -736,7 +736,6 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr) } ret = glusterd_volinfo_find (volname, &volinfo); - if (ret) goto out; @@ -806,39 +805,54 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) } ret = glusterd_volinfo_find (volname, &volinfo); - if (ret) goto out; - if (!(flags & GF_CLI_FLAG_OP_FORCE)) { - if (_gf_false == glusterd_is_volume_started (volinfo)) { - snprintf (msg, sizeof(msg), "Volume %s " - "is not in the started state", volname); - gf_log ("", GF_LOG_ERROR, "Volume %s " - "has not been started", volname); - *op_errstr = gf_strdup (msg); - 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 "GEOREP" session"); - if (is_run) { - gf_log ("", GF_LOG_WARNING, GEOREP" sessions active" - "for the volume %s ", volname); - snprintf (msg, sizeof(msg), GEOREP" sessions are active " - "for the volume '%s'.\nUse 'volume "GEOREP" " - "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; - } + /* If 'force' flag is given, no check is required */ + if (flags & GF_CLI_FLAG_OP_FORCE) + goto out; + if (_gf_false == glusterd_is_volume_started (volinfo)) { + snprintf (msg, sizeof(msg), "Volume %s " + "is not in the started state", volname); + gf_log ("", GF_LOG_ERROR, "Volume %s " + "has not been started", volname); + *op_errstr = gf_strdup (msg); + 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 "GEOREP" session"); + if (is_run) { + gf_log ("", GF_LOG_WARNING, GEOREP" sessions active" + "for the volume %s ", volname); + snprintf (msg, sizeof(msg), GEOREP" sessions are active " + "for the volume '%s'.\nUse 'volume "GEOREP" " + "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; + } + if (glusterd_is_defrag_on (volinfo)) { + snprintf (msg, sizeof(msg), "rebalance session is " + "in progress for the volume '%s'", volname); + gf_log (THIS->name, GF_LOG_WARNING, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; + } + if (volinfo->rb_status != GF_RB_STATUS_NONE) { + snprintf (msg, sizeof(msg), "replace-brick session is " + "in progress for the volume '%s'", volname); + gf_log (THIS->name, GF_LOG_WARNING, "%s", msg); + *op_errstr = gf_strdup (msg); + ret = -1; + goto out; } - out: -- cgit