From 51c6fa7a354826744de98a1c5c747955ae65850c Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Fri, 19 Jul 2013 14:23:32 +0000 Subject: glusterd: add check in remove-brick start variant The 'start' variant of the remove-brick command only applies at the dht level wherein we can remove all the bricks of a sub-volume (and remove multiple such sub-volumes) but not select bricks of it. This patch disallows removing individual replica bricks of multiple sub-volumes (i.e. reducing the replcia count of the volume) using remove-brick 'start'. The preferred method for such an operation is to use commit force. This patch also reverts the check to prevent removal of bricks from a replicate volume (commit 0d415f7) BUG: 961669 Change-Id: I447ad27f73a0963b5e09fb317bf7267a7a5a6147 Signed-off-by: Ravishankar N Reviewed-on: http://review.gluster.org/5566 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index efb0941e..7c8e55be 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -744,17 +744,6 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) goto out; } - /*Do not allow remove-brick if the volume is a replicate volume*/ - if ((volinfo->type == GF_CLUSTER_TYPE_REPLICATE) && - (volinfo->brick_count == volinfo->replica_count)) { - snprintf (err_str, sizeof(err_str), - "Removing brick from a replicate volume " - "is not allowed"); - gf_log (this->name, GF_LOG_ERROR, "%s", err_str); - ret = -1; - goto out; - } - if (!replica_count && (volinfo->type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) && (volinfo->brick_count == volinfo->dist_leaf_count)) { @@ -1371,6 +1360,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) glusterd_volinfo_t *volinfo = NULL; char *errstr = NULL; int32_t brick_count = 0; + int32_t replica_cnt = 0; char msg[2048] = {0,}; int32_t flag = 0; gf1_op_commands cmd = GF_OP_CMD_NONE; @@ -1426,6 +1416,16 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr) case GF_OP_CMD_START: { + if ((volinfo->type == GF_CLUSTER_TYPE_REPLICATE) && + !dict_get_int32 (dict, "replica-count", &replica_cnt)) { + snprintf (msg, sizeof(msg), "Rebalancing not needed " + "when reducing replica count. Try without " + "the 'start' option"); + errstr = gf_strdup (msg); + gf_log (this->name, GF_LOG_ERROR, "%s", errstr); + goto out; + } + if (GLUSTERD_STATUS_STARTED != volinfo->status) { snprintf (msg, sizeof (msg), "Volume %s needs to be " "started before remove-brick (you can use " -- cgit