summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
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
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')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c123
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c36
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c38
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c119
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c24
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h4
9 files changed, 217 insertions, 150 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 655f8a96a33..f488996c04d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -118,36 +118,43 @@ glusterd_handle_add_brick (rpcsvc_request_t *req)
goto out;
}
- if (!(ret = glusterd_volinfo_find (volname, &volinfo))) {
- if (volinfo->type == GF_CLUSTER_TYPE_NONE)
- goto brick_val;
- if (!brick_count || !volinfo->sub_count)
- goto brick_val;
-
- total_bricks = volinfo->brick_count + brick_count;
- /* If the brick count is less than sub_count then, allow add-brick only for
- plain replicate volume since in plain stripe brick_count becoming less than
- the sub_count is not allowed */
- if (volinfo->brick_count < volinfo->sub_count &&
- (volinfo->type == GF_CLUSTER_TYPE_REPLICATE)) {
- if (total_bricks <= volinfo->sub_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",
- brick_count, (volinfo->type == 1)? "STRIPE":
- "REPLICATE", volinfo->sub_count);
- gf_log("glusterd", GF_LOG_ERROR, "%s", err_str);
- ret = -1;
- goto out;
- }
- } else {
+ ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret) {
snprintf (err_str, sizeof (err_str), "Unable to get volinfo "
"for volume name %s", volname);
gf_log ("glusterd", GF_LOG_ERROR, "%s", err_str);
goto out;
+
+ }
+
+ /* If any of this is true, some thing is wrong */
+ if (!brick_count || !volinfo->sub_count) {
+ ret = -1;
+ snprintf (err_str, sizeof (err_str), "number of brick count "
+ "for volume name %s is wrong", volname);
+ goto out;
+ }
+
+ if (volinfo->type == GF_CLUSTER_TYPE_NONE)
+ goto brick_val;
+
+ total_bricks = volinfo->brick_count + brick_count;
+ /* If the brick count is less than dist_leaf_count then, allow
+ add-brick only for plain replicate volume since in plain stripe
+ brick_count becoming less than the dist_leaf_count is not allowed */
+ if (volinfo->brick_count < volinfo->dist_leaf_count &&
+ (volinfo->type == GF_CLUSTER_TYPE_REPLICATE)) {
+ if (total_bricks <= volinfo->replica_count)
+ goto brick_val;
+ }
+
+ if ((brick_count % volinfo->dist_leaf_count) != 0) {
+ snprintf(err_str, 2048, "Incorrect number of bricks"
+ " supplied %d with count %d",
+ brick_count, volinfo->dist_leaf_count);
+ gf_log("glusterd", GF_LOG_ERROR, "%s", err_str);
+ ret = -1;
+ goto out;
}
brick_val:
@@ -169,10 +176,8 @@ brick_val:
free_ptr = brick_list;
}
- gf_cmd_log ("Volume add-brick", "volname: %s type %s count:%d bricks:%s"
- ,volname, ((volinfo->type == 0)? "DEFAULT" : ((volinfo->type
- == 1)? "STRIPE": "REPLICATE")), brick_count, brick_list);
-
+ gf_cmd_log ("Volume add-brick", "volname: %s type %d count:%d bricks:%s"
+ ,volname, volinfo->type, brick_count, brick_list);
while ( i < brick_count) {
i++;
@@ -314,7 +319,7 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
/* Do not allow remove-brick if the volume is plain stripe */
if ((volinfo->type == GF_CLUSTER_TYPE_STRIPE) &&
- (volinfo->brick_count == volinfo->sub_count)) {
+ (volinfo->brick_count == volinfo->stripe_count)) {
snprintf (err_str, 2048, "Removing brick from a plain stripe is not allowed");
gf_log ("glusterd", GF_LOG_ERROR, "%s", err_str);
ret = -1;
@@ -324,11 +329,12 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
/* Do not allow remove-brick if the bricks given is less than the replica count
or stripe count */
if ((volinfo->type != GF_CLUSTER_TYPE_NONE) &&
- !(volinfo->brick_count <= volinfo->sub_count)) {
- if (volinfo->sub_count && (count % volinfo->sub_count != 0)) {
+ !(volinfo->brick_count <= volinfo->dist_leaf_count)) {
+ if (volinfo->dist_leaf_count &&
+ (count % volinfo->dist_leaf_count)) {
snprintf (err_str, 2048, "Remove brick incorrect"
" brick count of %d for %s %d",
- count, vol_type, volinfo->sub_count);
+ count, vol_type, volinfo->dist_leaf_count);
gf_log ("", GF_LOG_ERROR, "%s", err_str);
ret = -1;
goto out;
@@ -367,37 +373,38 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req)
i++;
if ((volinfo->type == GF_CLUSTER_TYPE_NONE) ||
- (volinfo->brick_count <= volinfo->sub_count))
+ (volinfo->brick_count <= volinfo->dist_leaf_count))
continue;
pos = 0;
list_for_each_entry (tmp, &volinfo->bricks, brick_list) {
- if ((!strcmp (tmp->hostname,brickinfo->hostname)) &&
- !strcmp (tmp->path, brickinfo->path)) {
- gf_log ("", GF_LOG_INFO, "Found brick");
- if (!sub_volume && volinfo->sub_count) {
- sub_volume = (pos / volinfo->
- sub_count) + 1;
- sub_volume_start = volinfo->sub_count *
- (sub_volume - 1);
- sub_volume_end = (volinfo->sub_count *
- sub_volume) -1 ;
- } else {
- if (pos < sub_volume_start ||
- pos >sub_volume_end) {
- ret = -1;
- snprintf(err_str, 2048,"Bricks"
- " not from same subvol"
- " for %s", vol_type);
- gf_log ("",GF_LOG_ERROR,
- "%s", err_str);
- goto out;
- }
+ if (strcmp (tmp->hostname,brickinfo->hostname) ||
+ strcmp (tmp->path, brickinfo->path)) {
+ pos++;
+ continue;
+ }
+
+ gf_log ("", GF_LOG_INFO, "Found brick");
+ if (!sub_volume && (volinfo->dist_leaf_count > 1)) {
+ sub_volume = (pos / volinfo->dist_leaf_count) + 1;
+ sub_volume_start = (volinfo->dist_leaf_count *
+ (sub_volume - 1));
+ sub_volume_end = (volinfo->dist_leaf_count *
+ sub_volume) - 1;
+ } else {
+ if (pos < sub_volume_start ||
+ pos >sub_volume_end) {
+ ret = -1;
+ snprintf(err_str, 2048,"Bricks not from"
+ " same subvol for %s",
+ vol_type);
+ gf_log ("", GF_LOG_ERROR,
+ "%s", err_str);
+ goto out;
}
- break;
}
- pos++;
+ break;
}
}
gf_cmd_log ("Volume remove-brick","volname: %s count:%d bricks:%s",
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 2ab80c2ff63..a62255c011c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -316,8 +316,8 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
- snprintf (key, 256, "volume%d.sub_count", count);
- ret = dict_set_int32 (volumes, key, volinfo->sub_count);
+ snprintf (key, 256, "volume%d.dist_count", count);
+ ret = dict_set_int32 (volumes, key, volinfo->dist_leaf_count);
if (ret)
goto out;
@@ -326,6 +326,11 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo,
if (ret)
goto out;
+ snprintf (key, 256, "volume%d.replica_count", count);
+ ret = dict_set_int32 (volumes, key, volinfo->replica_count);
+ if (ret)
+ goto out;
+
snprintf (key, 256, "volume%d.transport", count);
ret = dict_set_int32 (volumes, key, volinfo->transport_type);
if (ret)
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 84280498e8b..11cbeba0851 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2746,16 +2746,7 @@ glusterd_bricks_select_heal_volume (dict_t *dict, char **op_errstr)
goto out;
}
- if (volinfo->type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) {
- replica_count = volinfo->replica_count;
-
- } else if (volinfo->type == GF_CLUSTER_TYPE_REPLICATE) {
- replica_count = volinfo->sub_count;
-
- } else {
- GF_ASSERT (0);
- goto out;
- }
+ replica_count = volinfo->replica_count;
index = 1;
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index dab075db074..a18deceafb6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -599,6 +599,12 @@ glusterd_volume_exclude_options_write (int fd, glusterd_volinfo_t *volinfo)
if (ret)
goto out;
+ snprintf (buf, sizeof (buf), "%d", volinfo->replica_count);
+ ret = glusterd_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_REPLICA_CNT,
+ buf);
+ if (ret)
+ goto out;
+
snprintf (buf, sizeof (buf), "%d", volinfo->version);
ret = glusterd_store_save_value (fd, GLUSTERD_STORE_KEY_VOL_VERSION,
buf);
@@ -1827,6 +1833,9 @@ glusterd_store_retrieve_volume (char *volname)
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_STRIPE_CNT,
strlen (GLUSTERD_STORE_KEY_VOL_STRIPE_CNT))) {
volinfo->stripe_count = atoi (value);
+ } else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_REPLICA_CNT,
+ strlen (GLUSTERD_STORE_KEY_VOL_REPLICA_CNT))) {
+ volinfo->replica_count = atoi (value);
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TRANSPORT,
strlen (GLUSTERD_STORE_KEY_VOL_TRANSPORT))) {
volinfo->transport_type = atoi (value);
@@ -1883,13 +1892,32 @@ glusterd_store_retrieve_volume (char *volname)
ret = glusterd_store_iter_get_next (iter, &key, &value,
&op_errno);
}
+
+ /* backward compatibility */
+ {
+ /* would be true if type is 'GF_CLUSTER_TYPE_NONE' */
+ if (!volinfo->dist_leaf_count)
+ volinfo->dist_leaf_count = ((!volinfo->sub_count) ? 1 :
+ volinfo->sub_count);
+
+ /* would be true for all volumes in 3.1.x and 3.2.x,
+ or if type is not 'STRIPE_REPLICATE' (in 3.3 pre-releases) */
+ if (!volinfo->stripe_count)
+ volinfo->stripe_count = 1;
+
+ /* would be true for some pre-releases of 3.3, and all
+ releases of 3.1.x and 3.2.x */
+ if (!volinfo->replica_count)
+ volinfo->replica_count = (volinfo->dist_leaf_count /
+ volinfo->stripe_count);
+
+ volinfo->dist_leaf_count = (volinfo->stripe_count *
+ volinfo->replica_count);
+ }
+
if (op_errno != GD_STORE_EOF)
goto out;
- if (volinfo->stripe_count)
- volinfo->replica_count = (volinfo->sub_count /
- volinfo->stripe_count);
-
ret = glusterd_store_iter_destroy (iter);
if (ret)
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h
index 61bda195dfc..f1413955bed 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.h
+++ b/xlators/mgmt/glusterd/src/glusterd-store.h
@@ -50,7 +50,8 @@ typedef enum glusterd_store_ver_ac_{
#define GLUSTERD_STORE_KEY_VOL_STATUS "status"
#define GLUSTERD_STORE_KEY_VOL_PORT "port"
#define GLUSTERD_STORE_KEY_VOL_SUB_COUNT "sub_count"
-#define GLUSTERD_STORE_KEY_VOL_STRIPE_CNT "stripe_count"
+#define GLUSTERD_STORE_KEY_VOL_STRIPE_CNT "stripe_count"
+#define GLUSTERD_STORE_KEY_VOL_REPLICA_CNT "replica_count"
#define GLUSTERD_STORE_KEY_VOL_BRICK "brick"
#define GLUSTERD_STORE_KEY_VOL_VERSION "version"
#define GLUSTERD_STORE_KEY_VOL_TRANSPORT "transport-type"
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 59609971bd8..3681d4b9565 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1482,6 +1482,18 @@ glusterd_add_volume_to_dict (glusterd_volinfo_t *volinfo,
goto out;
memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.replica_count", count);
+ ret = dict_set_int32 (dict, key, volinfo->replica_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.dist_count", count);
+ ret = dict_set_int32 (dict, key, volinfo->dist_leaf_count);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "volume%d.ckusm", count);
ret = dict_set_int64 (dict, key, volinfo->cksum);
if (ret)
@@ -1958,11 +1970,27 @@ glusterd_import_volinfo (dict_t *vols, int count,
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "volume%d.stripe_count", count);
ret = dict_get_int32 (vols, key, &new_volinfo->stripe_count);
- if (!ret) {
- if (new_volinfo->stripe_count)
- new_volinfo->replica_count = (new_volinfo->sub_count /
- new_volinfo->stripe_count);
- }
+ if (ret)
+ gf_log (THIS->name, GF_LOG_INFO,
+ "peer is possibly old version");
+
+ /* not having a 'replica_count' key is not a error
+ (as peer may be of old version) */
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.replica_count", count);
+ ret = dict_get_int32 (vols, key, &new_volinfo->replica_count);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_INFO,
+ "peer is possibly old version");
+
+ /* not having a 'dist_count' key is not a error
+ (as peer may be of old version) */
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "volume%d.dist_count", count);
+ ret = dict_get_int32 (vols, key, &new_volinfo->dist_leaf_count);
+ if (ret)
+ gf_log (THIS->name, GF_LOG_INFO,
+ "peer is possibly old version");
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "volume%d.ckusm", count);
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;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 39cc02c8ee0..816ef9b184e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -921,7 +921,6 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
char *brick_list = NULL;
char *free_ptr = NULL;
char *saveptr = NULL;
- int32_t sub_count = 0;
char *trans_type = NULL;
char *str = NULL;
@@ -974,14 +973,19 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
goto out;
}
+ /* replica-count 1 means, no replication, file is in one brick only */
+ volinfo->replica_count = 1;
+ /* stripe-count 1 means, no striping, file is present as a whole */
+ volinfo->stripe_count = 1;
+
if (GF_CLUSTER_TYPE_REPLICATE == volinfo->type) {
ret = dict_get_int32 (dict, "replica-count",
- &sub_count);
+ &volinfo->replica_count);
if (ret)
goto out;
} else if (GF_CLUSTER_TYPE_STRIPE == volinfo->type) {
ret = dict_get_int32 (dict, "stripe-count",
- &sub_count);
+ &volinfo->stripe_count);
if (ret)
goto out;
} else if (GF_CLUSTER_TYPE_STRIPE_REPLICATE == volinfo->type) {
@@ -993,10 +997,18 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
&volinfo->replica_count);
if (ret)
goto out;
-
- sub_count = volinfo->stripe_count * volinfo->replica_count;
}
+ /* dist-leaf-count is the count of brick nodes for a given
+ subvolume of distribute */
+ volinfo->dist_leaf_count = (volinfo->stripe_count *
+ volinfo->replica_count);
+
+ /* Keep sub-count same as earlier, for the sake of backward
+ compatibility */
+ if (volinfo->dist_leaf_count > 1)
+ volinfo->sub_count = volinfo->dist_leaf_count;
+
ret = dict_get_str (dict, "transport", &trans_type);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Unable to get transport");
@@ -1025,8 +1037,6 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
volinfo->nfs_transport_type = GF_DEFAULT_NFS_TRANSPORT;
}
- volinfo->sub_count = sub_count;
-
if (bricks) {
brick_list = gf_strdup (bricks);
free_ptr = brick_list;
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index b49e7d6751f..f5a10189b0e 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -197,9 +197,11 @@ struct glusterd_volinfo_ {
struct list_head vol_list;
struct list_head bricks;
glusterd_volume_status status;
- int sub_count;
+ int sub_count; /* backward compatibility */
int stripe_count;
int replica_count;
+ int dist_leaf_count; /* Number of bricks in one
+ distribute subvolume */
int port;
glusterd_store_handle_t *shandle;
glusterd_store_handle_t *rb_shandle;