btrfs-progs: use btrfs_bg_type_is_stripey for enumerated lists

The striped profiles covering arbitrary number of devices are often
hardcoded so use the new helper btrfs_bg_type_is_stripey for that.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-10-07 01:29:47 +02:00
parent bc28dc6bea
commit b738de4446
2 changed files with 7 additions and 20 deletions

View File

@ -1226,11 +1226,7 @@ void print_device_chunks(struct device_info *devinfo,
size = calc_chunk_size(chunks_info_ptr+i);
num_stripes = chunks_info_ptr[i].num_stripes;
switch (profile) {
case BTRFS_BLOCK_GROUP_RAID0:
case BTRFS_BLOCK_GROUP_RAID5:
case BTRFS_BLOCK_GROUP_RAID6:
case BTRFS_BLOCK_GROUP_RAID10:
if (btrfs_bg_type_is_stripey(profile)) {
printf(" %s,%s/%llu:%*s%10s\n",
description,
r_mode,
@ -1238,14 +1234,12 @@ void print_device_chunks(struct device_info *devinfo,
(int)(20 - strlen(description) - strlen(r_mode)
- count_digits(num_stripes) - 1), "",
pretty_size_mode(size, unit_mode));
break;
default:
} else {
printf(" %s,%s:%*s%10s\n",
description,
r_mode,
(int)(20 - strlen(description) - strlen(r_mode)), "",
pretty_size_mode(size, unit_mode));
break;
}
allocated += size;

View File

@ -1572,9 +1572,7 @@ static int btrfs_get_device_extents(u64 chunk_object,
static int calc_num_stripes(u64 type)
{
if (type & (BTRFS_BLOCK_GROUP_RAID0 |
BTRFS_BLOCK_GROUP_RAID10 |
BTRFS_BLOCK_GROUP_RAID56_MASK))
if (btrfs_bg_type_is_stripey(type))
return 0;
else if (type & (BTRFS_BLOCK_GROUP_RAID1 |
BTRFS_BLOCK_GROUP_DUP))
@ -1789,11 +1787,6 @@ no_extent_record:
return 0;
}
#define BTRFS_ORDERED_RAID (BTRFS_BLOCK_GROUP_RAID0 | \
BTRFS_BLOCK_GROUP_RAID10 | \
BTRFS_BLOCK_GROUP_RAID5 | \
BTRFS_BLOCK_GROUP_RAID6)
static int btrfs_rebuild_chunk_stripes(struct recover_control *rc,
struct chunk_record *chunk)
{
@ -1805,10 +1798,10 @@ static int btrfs_rebuild_chunk_stripes(struct recover_control *rc,
* is we can reorder the stripes in the system metadata chunk.
*/
if ((chunk->type_flags & BTRFS_BLOCK_GROUP_METADATA) &&
(chunk->type_flags & BTRFS_ORDERED_RAID))
btrfs_bg_type_is_stripey(chunk->type_flags))
ret =btrfs_rebuild_ordered_meta_chunk_stripes(rc, chunk);
else if ((chunk->type_flags & BTRFS_BLOCK_GROUP_DATA) &&
(chunk->type_flags & BTRFS_ORDERED_RAID))
btrfs_bg_type_is_stripey(chunk->type_flags))
ret = 1; /* Be handled after the fs is opened. */
else
ret = btrfs_rebuild_unordered_chunk_stripes(rc, chunk);
@ -2183,8 +2176,8 @@ static int btrfs_rebuild_ordered_data_chunk_stripes(struct recover_control *rc,
u8 flags;
list_for_each_entry_safe(chunk, next, &rc->unrepaired_chunks, list) {
if ((chunk->type_flags & BTRFS_BLOCK_GROUP_DATA)
&& (chunk->type_flags & BTRFS_ORDERED_RAID)) {
if ((chunk->type_flags & BTRFS_BLOCK_GROUP_DATA) &&
btrfs_bg_type_is_stripey(chunk->type_flags)) {
flags = 0;
err = rebuild_raid_data_chunk_stripes(rc, root, chunk,
&flags);