btrfs-progs: introduce helper for striped profiles

There are several profiles like raid0, raid10, raid5 and raid6 that can
span as many devices as possible and need special handling for the
stripe calculations. Provide a helper to identify the profiles in a
simple way.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-10-07 01:22:33 +02:00
parent a25a5cc2c0
commit bc28dc6bea
2 changed files with 12 additions and 0 deletions

View File

@ -245,6 +245,17 @@ int btrfs_bg_type_to_sub_stripes(u64 flags)
return btrfs_raid_array[index].sub_stripes;
}
/*
* Number of stripes is not fixed and depends on the number of devices,
* utilizing as many as possible (RAID0/RAID10/RAID5/RAID6/...).
*/
bool btrfs_bg_type_is_stripey(u64 flags)
{
const int index = btrfs_bg_flags_to_raid_index(flags);
return btrfs_raid_array[index].devs_max == 0;
}
u64 btrfs_bg_flags_for_device_num(int number)
{
int i;

View File

@ -313,5 +313,6 @@ int btrfs_bg_type_to_ncopies(u64 flags);
int btrfs_bg_type_to_nparity(u64 flags);
int btrfs_bg_type_to_sub_stripes(u64 flags);
u64 btrfs_bg_flags_for_device_num(int number);
bool btrfs_bg_type_is_stripey(u64 flags);
#endif