From 43d36d456314f6d4e67c3d8f06cceb585f467915 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Wed, 8 Sep 2010 08:53:21 +0000 Subject: allow brick to be added in a plain replicate volume if a brick is removed Signed-off-by: Raghavendra Bhat Signed-off-by: Vijay Bellur BUG: 1574 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1574 --- xlators/mgmt/glusterd/src/glusterd-handler.c | 6 +++++ xlators/mgmt/glusterd/src/glusterd-volgen.c | 34 +++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 6dee0355d3d..6b5b01c770d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -1386,6 +1386,12 @@ glusterd_handle_add_brick (rpcsvc_request_t *req) goto brick_val; if (!brick_count || !volinfo->sub_count) goto brick_val; + + if (volinfo->brick_count < volinfo->sub_count) { + if ((volinfo->sub_count - volinfo->brick_count) == brick_count) + goto brick_val; + } + if ((brick_count % volinfo->sub_count) != 0) { snprintf(err_str, 2048, "Incorrect number of bricks" " supplied %d for type %s with count %d", diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index d368e5c98aa..ce6547e6e9e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -1477,16 +1477,34 @@ generate_client_volfile (glusterd_volinfo_t *volinfo, char *filename) num_bricks++; if (GF_CLUSTER_TYPE_REPLICATE == volinfo->type) { - gf_log ("", GF_LOG_DEBUG, - "Volfile is distributed-replicated"); - replicate_count = volinfo->sub_count; - dist_count = num_bricks / replicate_count; + if (volinfo->brick_count <= volinfo->sub_count) { + gf_log ("", GF_LOG_DEBUG, + "Volfile is plain replicated"); + replicate_count = volinfo->sub_count; + dist_count = num_bricks / replicate_count; + if (!dist_count) { + replicate_count = num_bricks; + dist_count = num_bricks / replicate_count; + } + } else { + gf_log ("", GF_LOG_DEBUG, + "Volfile is distributed-replicated"); + replicate_count = volinfo->sub_count; + dist_count = num_bricks / replicate_count; + } } else if (GF_CLUSTER_TYPE_STRIPE == volinfo->type) { - gf_log ("", GF_LOG_DEBUG, - "Volfile is distributed-striped"); - stripe_count = volinfo->sub_count; - dist_count = num_bricks / stripe_count; + if (volinfo->brick_count == volinfo->sub_count) { + gf_log ("", GF_LOG_DEBUG, + "Volfile is plain striped"); + stripe_count = volinfo->sub_count; + dist_count = num_bricks / stripe_count; + } else { + gf_log ("", GF_LOG_DEBUG, + "Volfile is distributed-striped"); + stripe_count = volinfo->sub_count; + dist_count = num_bricks / stripe_count; + } } else { gf_log ("", GF_LOG_DEBUG, "Volfile is plain distributed"); -- cgit