mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-11 03:31:17 +00:00
btrfs-progs: zoned: implement RAID10 zone info loading
Just same as the kernel side. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
915e15da2e
commit
5042af1c4f
@ -1092,6 +1092,39 @@ static int btrfs_load_block_group_raid0(struct btrfs_fs_info *fs_info,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int btrfs_load_block_group_raid10(struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_block_group *bg,
|
||||
struct map_lookup *map,
|
||||
struct zone_info *zone_info,
|
||||
unsigned long *active)
|
||||
{
|
||||
if ((map->type & BTRFS_BLOCK_GROUP_DATA) && !fs_info->stripe_root) {
|
||||
btrfs_err(fs_info, "zoned: data %s needs raid-stripe-tree",
|
||||
btrfs_bg_type_to_raid_name(map->type));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < map->num_stripes; i++) {
|
||||
if (zone_info[i].alloc_offset == WP_MISSING_DEV ||
|
||||
zone_info[i].alloc_offset == WP_CONVENTIONAL)
|
||||
continue;
|
||||
|
||||
if (test_bit(0, active) != test_bit(i, active)) {
|
||||
return -EIO;
|
||||
} else {
|
||||
if (test_bit(0, active))
|
||||
bg->zone_is_active = 1;
|
||||
}
|
||||
|
||||
if ((i % map->sub_stripes) == 0) {
|
||||
bg->zone_capacity += zone_info[i].capacity;
|
||||
bg->alloc_offset += zone_info[i].alloc_offset;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_block_group *cache)
|
||||
{
|
||||
@ -1192,8 +1225,8 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
|
||||
ret = btrfs_load_block_group_raid0(fs_info, cache, map, zone_info, active);
|
||||
break;
|
||||
case BTRFS_BLOCK_GROUP_RAID10:
|
||||
/* Temporarily fails these case, until following commits. */
|
||||
fallthrough;
|
||||
ret = btrfs_load_block_group_raid10(fs_info, cache, map, zone_info, active);
|
||||
break;
|
||||
case BTRFS_BLOCK_GROUP_RAID5:
|
||||
case BTRFS_BLOCK_GROUP_RAID6:
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user