summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-store.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-store.c
parent1b096c3ff0a4c25ff22a32d9594d2e289a3d67ea (diff)
glusterd: cleanup of volinfo '*_count' definitions
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-store.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index dab075db0..a18deceaf 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)