exofs: groups support

* _calc_stripe_info() changes to accommodate for grouping
  calculations. Returns additional information

* old _prepare_pages() becomes _prepare_one_group()
  which stores pages belonging to one device group.

* New _prepare_for_striping iterates on all groups calling
  _prepare_one_group().

* Enable mounting of groups data_maps (group_width != 0)

[QUESTION]
what is faster A or B;
A.	x += stride;
	x = x % width + first_x;

B	x += stride
	if (x < last_x)
		x = first_x;

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index 8f4e4b3..6cf5e4e 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -323,11 +323,7 @@
 	sbi->data_map.odm_raid_algorithm  =
 				le32_to_cpu(dt->dt_data_map.cb_raid_algorithm);
 
-/* FIXME: Only raid0 !group_width/depth for now. if not so, do not mount */
-	if (sbi->data_map.odm_group_width || sbi->data_map.odm_group_depth) {
-		EXOFS_ERR("Group width/depth not supported\n");
-		return -EINVAL;
-	}
+/* FIXME: Only raid0 for now. if not so, do not mount */
 	if (sbi->data_map.odm_num_comps != numdevs) {
 		EXOFS_ERR("odm_num_comps(%u) != numdevs(%u)\n",
 			  sbi->data_map.odm_num_comps, numdevs);
@@ -343,14 +339,6 @@
 		return -EINVAL;
 	}
 
-	stripe_length = sbi->data_map.odm_stripe_unit *
-			(numdevs / (sbi->data_map.odm_mirror_cnt + 1));
-	if (stripe_length >= (1ULL << 32)) {
-		EXOFS_ERR("Total Stripe length(0x%llx)"
-			  " >= 32bit is not supported\n", _LLU(stripe_length));
-		return -EINVAL;
-	}
-
 	if (0 != (sbi->data_map.odm_stripe_unit & ~PAGE_MASK)) {
 		EXOFS_ERR("Stripe Unit(0x%llx)"
 			  " must be Multples of PAGE_SIZE(0x%lx)\n",
@@ -360,8 +348,36 @@
 
 	sbi->layout.stripe_unit = sbi->data_map.odm_stripe_unit;
 	sbi->layout.mirrors_p1 = sbi->data_map.odm_mirror_cnt + 1;
-	sbi->layout.group_width = sbi->data_map.odm_num_comps /
+
+	if (sbi->data_map.odm_group_width) {
+		sbi->layout.group_width = sbi->data_map.odm_group_width;
+		sbi->layout.group_depth = sbi->data_map.odm_group_depth;
+		if (!sbi->layout.group_depth) {
+			EXOFS_ERR("group_depth == 0 && group_width != 0\n");
+			return -EINVAL;
+		}
+		sbi->layout.group_count = sbi->data_map.odm_num_comps /
+						sbi->layout.mirrors_p1 /
+						sbi->data_map.odm_group_width;
+	} else {
+		if (sbi->data_map.odm_group_depth) {
+			printk(KERN_NOTICE "Warning: group_depth ignored "
+				"group_width == 0 && group_depth == %d\n",
+				sbi->data_map.odm_group_depth);
+			sbi->data_map.odm_group_depth = 0;
+		}
+		sbi->layout.group_width = sbi->data_map.odm_num_comps /
 							sbi->layout.mirrors_p1;
+		sbi->layout.group_depth = -1;
+		sbi->layout.group_count = 1;
+	}
+
+	stripe_length = (u64)sbi->layout.group_width * sbi->layout.stripe_unit;
+	if (stripe_length >= (1ULL << 32)) {
+		EXOFS_ERR("Total Stripe length(0x%llx)"
+			  " >= 32bit is not supported\n", _LLU(stripe_length));
+		return -EINVAL;
+	}
 
 	return 0;
 }
@@ -540,6 +556,8 @@
 	sbi->layout.stripe_unit = PAGE_SIZE;
 	sbi->layout.mirrors_p1 = 1;
 	sbi->layout.group_width = 1;
+	sbi->layout.group_depth = -1;
+	sbi->layout.group_count = 1;
 	sbi->layout.s_ods[0] = od;
 	sbi->layout.s_numdevs = 1;
 	sbi->layout.s_pid = opts->pid;