summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-volgen.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-09-15 12:57:44 +0530
committerVijay Bellur <vijay@gluster.com>2011-09-23 06:48:32 -0700
commit76580479033087f6dde080c27618baf19b18b658 (patch)
tree89a6b37046df9dc859e7f8ac7acd3f9115c69c2f /xlators/mgmt/glusterd/src/glusterd-volgen.c
parent1b096c3ff0a4c25ff22a32d9594d2e289a3d67ea (diff)
glusterd: cleanup of volinfo '*_count' definitionsv3.3.0qa11
earlier, sub_count was having different meaning depending on the volume type. now, for replica and stripe count, one can directly access the 'replica_count' or 'stripe_count' to get the corresponding value from the volume info. 'sub_count' is preserved as is for backward compatibility. there is a new variable 'dist_leaf_count' to get info about how many bricks are present in one distribute sub volume. Change-Id: I5ea1c8f9ae08f584cca63b91ba69035c7e4350ca BUG: 3158 Reviewed-on: http://review.gluster.com/435 Reviewed-by: Krishnan Parthasarathi <kp@gluster.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volgen.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c119
1 files changed, 57 insertions, 62 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 77478f3658e..e1934493a6b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1869,17 +1869,17 @@ volgen_graph_build_clients (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (volinfo->brick_count == 0) {
gf_log ("", GF_LOG_ERROR,
"volume inconsistency: brick count is 0");
-
goto out;
}
- if (volinfo->sub_count && volinfo->sub_count < volinfo->brick_count &&
- volinfo->brick_count % volinfo->sub_count != 0) {
+
+ if ((volinfo->dist_leaf_count < volinfo->brick_count) &&
+ ((volinfo->brick_count % volinfo->dist_leaf_count) != 0)) {
gf_log ("", GF_LOG_ERROR,
"volume inconsistency: "
"total number of bricks (%d) is not divisible with "
"number of bricks per cluster (%d) in a multi-cluster "
"setup",
- volinfo->brick_count, volinfo->sub_count);
+ volinfo->brick_count, volinfo->dist_leaf_count);
goto out;
}
@@ -1941,7 +1941,7 @@ volgen_graph_build_clusters (volgen_graph_t *graph,
txl = first_of (graph);
for (trav = txl; --child_count; trav = trav->next);
for (;; trav = trav->prev) {
- if (i % sub_count == 0) {
+ if ((i % sub_count) == 0) {
xl = volgen_graph_add_nolink (graph, xl_type,
xl_namefmt, volname, j);
if (!xl) {
@@ -2105,62 +2105,62 @@ volume_volgen_graph_build_clusters (volgen_graph_t *graph,
int dist_count = 0;
int ret = -1;
- if (volinfo->sub_count > 1) {
- switch (volinfo->type) {
- case GF_CLUSTER_TYPE_REPLICATE:
- clusters = volgen_graph_build_clusters (graph, volinfo,
- replicate_args[0],
- replicate_args[1],
- volinfo->brick_count,
- volinfo->sub_count);
- if (clusters < 0)
- goto out;
- break;
- case GF_CLUSTER_TYPE_STRIPE:
- clusters = volgen_graph_build_clusters (graph, volinfo,
- stripe_args[0],
- stripe_args[1],
- volinfo->brick_count,
- volinfo->sub_count);
- if (clusters < 0)
- goto out;
- break;
- case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
- /* Replicate after the clients, then stripe */
- if (volinfo->replica_count == 0)
- return -1;
- clusters = volgen_graph_build_clusters (graph, volinfo,
- replicate_args[0],
- replicate_args[1],
- volinfo->brick_count,
- volinfo->replica_count);
- if (clusters < 0)
- goto out;
+ if (!volinfo->dist_leaf_count)
+ goto out;
- rclusters = volinfo->brick_count/volinfo->replica_count;
- GF_ASSERT (rclusters == clusters);
- clusters = volgen_graph_build_clusters (graph, volinfo,
- stripe_args[0],
- stripe_args[1],
- rclusters,
- volinfo->stripe_count);
- if (clusters < 0)
- goto out;
- break;
- default:
- gf_log ("", GF_LOG_ERROR, "volume inconsistency: "
- "unrecognized clustering type");
+ if (volinfo->dist_leaf_count == 1)
+ goto build_distribute;
+
+ /* All other cases, it will have one or the other cluster type */
+ switch (volinfo->type) {
+ case GF_CLUSTER_TYPE_REPLICATE:
+ clusters = volgen_graph_build_clusters (graph, volinfo,
+ replicate_args[0],
+ replicate_args[1],
+ volinfo->brick_count,
+ volinfo->replica_count);
+ if (clusters < 0)
+ goto out;
+ break;
+ case GF_CLUSTER_TYPE_STRIPE:
+ clusters = volgen_graph_build_clusters (graph, volinfo,
+ stripe_args[0],
+ stripe_args[1],
+ volinfo->brick_count,
+ volinfo->stripe_count);
+ if (clusters < 0)
+ goto out;
+ break;
+ case GF_CLUSTER_TYPE_STRIPE_REPLICATE:
+ /* Replicate after the clients, then stripe */
+ if (volinfo->replica_count == 0)
+ goto out;
+ clusters = volgen_graph_build_clusters (graph, volinfo,
+ replicate_args[0],
+ replicate_args[1],
+ volinfo->brick_count,
+ volinfo->replica_count);
+ if (clusters < 0)
goto out;
- }
- }
- if (volinfo->sub_count) {
- dist_count = volinfo->brick_count / volinfo->sub_count;
- GF_ASSERT (dist_count == clusters);
- } else {
- dist_count = volinfo->brick_count;
+ rclusters = volinfo->brick_count / volinfo->replica_count;
+ GF_ASSERT (rclusters == clusters);
+ clusters = volgen_graph_build_clusters (graph, volinfo,
+ stripe_args[0],
+ stripe_args[1],
+ rclusters,
+ volinfo->stripe_count);
+ if (clusters < 0)
+ goto out;
+ break;
+ default:
+ gf_log ("", GF_LOG_ERROR, "volume inconsistency: "
+ "unrecognized clustering type");
+ goto out;
}
+build_distribute:
+ dist_count = volinfo->brick_count / volinfo->dist_leaf_count;
if (dist_count > 1) {
ret = volgen_graph_build_dht_cluster (graph, volinfo,
dist_count);
@@ -2460,12 +2460,7 @@ build_shd_graph (volgen_graph_t *graph, dict_t *mod_dict)
if (voliter->status != GLUSTERD_STATUS_STARTED)
continue;
- if (voliter->type == GF_CLUSTER_TYPE_REPLICATE)
- replica_count = voliter->sub_count;
- else if (voliter->type == GF_CLUSTER_TYPE_STRIPE_REPLICATE)
- replica_count = voliter->replica_count;
- else
- continue;
+ replica_count = voliter->replica_count;
valid_config = _gf_true;