Skip to content

Commit 5042af1

Browse files
naotakdave
authored andcommitted
btrfs-progs: zoned: implement RAID10 zone info loading
Just same as 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 915e15d commit 5042af1

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

kernel-shared/zoned.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,39 @@ static int btrfs_load_block_group_raid0(struct btrfs_fs_info *fs_info,
10921092
return 0;
10931093
}
10941094

1095+
static int btrfs_load_block_group_raid10(struct btrfs_fs_info *fs_info,
1096+
struct btrfs_block_group *bg,
1097+
struct map_lookup *map,
1098+
struct zone_info *zone_info,
1099+
unsigned long *active)
1100+
{
1101+
if ((map->type & BTRFS_BLOCK_GROUP_DATA) && !fs_info->stripe_root) {
1102+
btrfs_err(fs_info, "zoned: data %s needs raid-stripe-tree",
1103+
btrfs_bg_type_to_raid_name(map->type));
1104+
return -EINVAL;
1105+
}
1106+
1107+
for (int i = 0; i < map->num_stripes; i++) {
1108+
if (zone_info[i].alloc_offset == WP_MISSING_DEV ||
1109+
zone_info[i].alloc_offset == WP_CONVENTIONAL)
1110+
continue;
1111+
1112+
if (test_bit(0, active) != test_bit(i, active)) {
1113+
return -EIO;
1114+
} else {
1115+
if (test_bit(0, active))
1116+
bg->zone_is_active = 1;
1117+
}
1118+
1119+
if ((i % map->sub_stripes) == 0) {
1120+
bg->zone_capacity += zone_info[i].capacity;
1121+
bg->alloc_offset += zone_info[i].alloc_offset;
1122+
}
1123+
}
1124+
1125+
return 0;
1126+
}
1127+
10951128
int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
10961129
struct btrfs_block_group *cache)
10971130
{
@@ -1192,8 +1225,8 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
11921225
ret = btrfs_load_block_group_raid0(fs_info, cache, map, zone_info, active);
11931226
break;
11941227
case BTRFS_BLOCK_GROUP_RAID10:
1195-
/* Temporarily fails these case, until following commits. */
1196-
fallthrough;
1228+
ret = btrfs_load_block_group_raid10(fs_info, cache, map, zone_info, active);
1229+
break;
11971230
case BTRFS_BLOCK_GROUP_RAID5:
11981231
case BTRFS_BLOCK_GROUP_RAID6:
11991232
default:

0 commit comments

Comments
 (0)