mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-31 18:52:05 +00:00
btrfs-progs: fi usage: use one formula for chunk size calculation
The profile descriptions allow us to use a single formula to calculate chunk size. Right now there are no profiles with parity (raid5-like) and sub_stripes (raid10-like), which makes it easier. - parity stripes are subtracted from the total count - then divided by number of sub stripes Practically speaking, 1:1 copy profiles do not have any adjustments. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
7d10a07455
commit
7674317139
@ -810,17 +810,13 @@ int load_chunk_and_device_info(int fd, struct chunk_info **chunkinfo,
|
||||
*/
|
||||
static u64 calc_chunk_size(struct chunk_info *ci)
|
||||
{
|
||||
if (ci->type & BTRFS_BLOCK_GROUP_RAID0)
|
||||
return ci->size / ci->num_stripes;
|
||||
else if (ci->type & BTRFS_BLOCK_GROUP_RAID1_MASK)
|
||||
return ci->size ;
|
||||
else if (ci->type & BTRFS_BLOCK_GROUP_DUP)
|
||||
return ci->size ;
|
||||
else if (ci->type & BTRFS_BLOCK_GROUP_RAID56_MASK)
|
||||
return ci->size / (ci->num_stripes - btrfs_bg_type_to_nparity(ci->type));
|
||||
else if (ci->type & BTRFS_BLOCK_GROUP_RAID10)
|
||||
return ci->size / (ci->num_stripes / btrfs_bg_type_to_sub_stripes(ci->type));
|
||||
return ci->size;
|
||||
u32 div;
|
||||
|
||||
/* No parity + sub_stripes, so order of "-" and "/" does not matter */
|
||||
div = (ci->num_stripes - btrfs_bg_type_to_nparity(ci->type)) /
|
||||
btrfs_bg_type_to_sub_stripes(ci->type);
|
||||
|
||||
return ci->size / div;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user