Commit 7735cd75 authored by David Sterba's avatar David Sterba

btrfs: scrub: factor out common scrub_stripe constraints

There are common values set for the stripe constraints, some of them
are already factored out. Do that for increment and mirror_num as well.
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 1aeb6b56
...@@ -3204,28 +3204,23 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, ...@@ -3204,28 +3204,23 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
physical = map->stripes[num].physical; physical = map->stripes[num].physical;
offset = 0; offset = 0;
nstripes = div64_u64(length, map->stripe_len); nstripes = div64_u64(length, map->stripe_len);
mirror_num = 1;
increment = map->stripe_len;
if (map->type & BTRFS_BLOCK_GROUP_RAID0) { if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
offset = map->stripe_len * num; offset = map->stripe_len * num;
increment = map->stripe_len * map->num_stripes; increment = map->stripe_len * map->num_stripes;
mirror_num = 1;
} else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
int factor = map->num_stripes / map->sub_stripes; int factor = map->num_stripes / map->sub_stripes;
offset = map->stripe_len * (num / map->sub_stripes); offset = map->stripe_len * (num / map->sub_stripes);
increment = map->stripe_len * factor; increment = map->stripe_len * factor;
mirror_num = num % map->sub_stripes + 1; mirror_num = num % map->sub_stripes + 1;
} else if (map->type & BTRFS_BLOCK_GROUP_RAID1_MASK) { } else if (map->type & BTRFS_BLOCK_GROUP_RAID1_MASK) {
increment = map->stripe_len;
mirror_num = num % map->num_stripes + 1; mirror_num = num % map->num_stripes + 1;
} else if (map->type & BTRFS_BLOCK_GROUP_DUP) { } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
increment = map->stripe_len;
mirror_num = num % map->num_stripes + 1; mirror_num = num % map->num_stripes + 1;
} else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
get_raid56_logic_offset(physical, num, map, &offset, NULL); get_raid56_logic_offset(physical, num, map, &offset, NULL);
increment = map->stripe_len * nr_data_stripes(map); increment = map->stripe_len * nr_data_stripes(map);
mirror_num = 1;
} else {
increment = map->stripe_len;
mirror_num = 1;
} }
path = btrfs_alloc_path(); path = btrfs_alloc_path();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment