From e397772955f10f22fcb920f34a32efd859fb727d Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Mon, 3 Oct 2011 15:25:12 +0530 Subject: glusterd: Handle restoring of volumes created in older versions. Change-Id: Idd9cb9d05122750ac78410b8f5a080104d6c1e0a BUG: 3685 Reviewed-on: http://review.gluster.com/554 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- xlators/mgmt/glusterd/src/glusterd-store.c | 43 +++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-store.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index a18deceaf..823fb37cd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1895,21 +1895,34 @@ glusterd_store_retrieve_volume (char *volname) /* 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); + + switch (volinfo->type) { + + case GF_CLUSTER_TYPE_NONE: + volinfo->stripe_count = 1; + volinfo->replica_count = 1; + break; + + case GF_CLUSTER_TYPE_STRIPE: + volinfo->stripe_count = volinfo->sub_count; + volinfo->replica_count = 1; + break; + + case GF_CLUSTER_TYPE_REPLICATE: + volinfo->stripe_count = 1; + volinfo->replica_count = volinfo->sub_count; + break; + + case GF_CLUSTER_TYPE_STRIPE_REPLICATE: + /* Introduced in 3.3 */ + GF_ASSERT (volinfo->stripe_count > 0); + GF_ASSERT (volinfo->replica_count > 0); + break; + + default: + GF_ASSERT (0); + break; + } volinfo->dist_leaf_count = (volinfo->stripe_count * volinfo->replica_count); -- cgit