From eb7c8dd03d84d7c3917d18a59d86c379382c8b2d Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Sat, 5 May 2012 09:54:22 +0530 Subject: glusterd: remove-brick: add more error handling with this, we can make sure, all wrong patterns in CLI can be reported with proper message back to user, instead of resulting in an wrong volume type. Change-Id: Ib461956dd7d51f7f81c19c27112d44c2adb3a66d Signed-off-by: Amar Tumballi BUG: 803711 Reviewed-on: http://review.gluster.com/3278 Tested-by: Gluster Build System Reviewed-by: Kaushal M Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 39 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 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 4bb6c5115a7..72418684649 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -684,10 +684,33 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req) goto out; } + if (!replica_count && + (volinfo->type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) && + (volinfo->brick_count == volinfo->dist_leaf_count)) { + snprintf (err_str, 2048, + "Removing bricks from stripe-replicate" + " configuration is not allowed without reducing " + "replica or stripe count explicitly."); + gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); + ret = -1; + goto out; + } + + if (!replica_count && + (volinfo->type == GF_CLUSTER_TYPE_REPLICATE) && + (volinfo->brick_count == volinfo->dist_leaf_count)) { + snprintf (err_str, 2048, + "Removing bricks from replicate configuration " + "is not allowed without reducing replica count " + "explicitly."); + gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); + ret = -1; + goto out; + } + /* Do not allow remove-brick if the bricks given is less than the replica count or stripe count */ - if (!replica_count && (volinfo->type != GF_CLUSTER_TYPE_NONE) && - !(volinfo->brick_count <= volinfo->dist_leaf_count)) { + if (!replica_count && (volinfo->type != GF_CLUSTER_TYPE_NONE)) { if (volinfo->dist_leaf_count && (count % volinfo->dist_leaf_count)) { snprintf (err_str, 2048, "Remove brick incorrect" @@ -699,18 +722,6 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req) } } - if (!replica_count && - (volinfo->type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) && - (volinfo->brick_count == volinfo->dist_leaf_count)) { - snprintf (err_str, 2048, - "Removing bricks from stripe-replicate" - " configuration is not allowed without reducing " - "replica or stripe count explicitly."); - gf_log (THIS->name, GF_LOG_ERROR, "%s", err_str); - ret = -1; - goto out; - } - brick_list = GF_MALLOC (120000 * sizeof(*brick_list),gf_common_mt_char); if (!brick_list) { -- cgit