@@ -3076,16 +3076,19 @@ again:
multi->stripes[i].dev = map->stripes[stripe_index].dev;
if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
- u64 stripes;
- int last_stripe = (stripe_nr_end - 1) %
- map->num_stripes;
+ u64 stripes = stripe_nr_end - 1;
+ int last_stripe = do_div(stripes,
+ map->num_stripes);
int j;
for (j = 0; j < map->num_stripes; j++) {
- if ((stripe_nr_end - 1 - j) %
- map->num_stripes == stripe_index)
+ stripes = stripe_nr_end - 1 - j;
+
+ if (do_div(stripes, map->num_stripes) ==
+ stripe_index)
break;
}
+
stripes = stripe_nr_end - 1 - j;
do_div(stripes, map->num_stripes);
multi->stripes[i].length = map->stripe_len *
@@ -3100,18 +3103,22 @@ again:
multi->stripes[i].length -=
stripe_end_offset;
} else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
- u64 stripes;
+ u64 stripes = stripe_nr_end - 1;
int j;
int factor = map->num_stripes /
map->sub_stripes;
- int last_stripe = (stripe_nr_end - 1) % factor;
+ int last_stripe = do_div(stripes, factor);
+
last_stripe *= map->sub_stripes;
for (j = 0; j < factor; j++) {
- if ((stripe_nr_end - 1 - j) % factor ==
+ stripes = stripe_nr_end - 1 - j;
+
+ if (do_div(stripes, factor) ==
stripe_index / map->sub_stripes)
break;
}
+
stripes = stripe_nr_end - 1 - j;
do_div(stripes, factor);
multi->stripes[i].length = map->stripe_len *