Skip to content

Commit 915e15d

Browse files
naotakdave
authored andcommitted
btrfs-progs: zoned: implement RAID0 zone info loading
Implement it just like the kernel side. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 03a70d0 commit 915e15d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

kernel-shared/zoned.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,36 @@ static int btrfs_load_block_group_raid1(struct btrfs_fs_info *fs_info,
10621062
return 0;
10631063
}
10641064

1065+
static int btrfs_load_block_group_raid0(struct btrfs_fs_info *fs_info,
1066+
struct btrfs_block_group *bg,
1067+
struct map_lookup *map,
1068+
struct zone_info *zone_info,
1069+
unsigned long *active)
1070+
{
1071+
if ((map->type & BTRFS_BLOCK_GROUP_DATA) && !fs_info->stripe_root) {
1072+
btrfs_err(fs_info, "zoned: data %s needs raid-stripe-tree",
1073+
btrfs_bg_type_to_raid_name(map->type));
1074+
return -EINVAL;
1075+
}
1076+
1077+
for (int i = 0; i < map->num_stripes; i++) {
1078+
if (zone_info[i].alloc_offset == WP_MISSING_DEV ||
1079+
zone_info[i].alloc_offset == WP_CONVENTIONAL)
1080+
continue;
1081+
1082+
if (test_bit(0, active) != test_bit(i, active)) {
1083+
return -EIO;
1084+
} else {
1085+
if (test_bit(0, active))
1086+
bg->zone_is_active = 1;
1087+
}
1088+
bg->zone_capacity += zone_info[i].capacity;
1089+
bg->alloc_offset += zone_info[i].alloc_offset;
1090+
}
1091+
1092+
return 0;
1093+
}
1094+
10651095
int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
10661096
struct btrfs_block_group *cache)
10671097
{
@@ -1159,6 +1189,8 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
11591189
ret = btrfs_load_block_group_raid1(fs_info, cache, map, zone_info, active);
11601190
break;
11611191
case BTRFS_BLOCK_GROUP_RAID0:
1192+
ret = btrfs_load_block_group_raid0(fs_info, cache, map, zone_info, active);
1193+
break;
11621194
case BTRFS_BLOCK_GROUP_RAID10:
11631195
/* Temporarily fails these case, until following commits. */
11641196
fallthrough;

0 commit comments

Comments
 (0)