Skip to content

Commit b415baf

Browse files
naotakdave
authored andcommitted
btrfs-progs: zoned: implement DUP zone info loading
DUP support is added like 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>
1 parent 9e0c30a commit b415baf

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

kernel-shared/zoned.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,46 @@ static int btrfs_load_block_group_single(struct btrfs_fs_info *fs_info,
977977
return 0;
978978
}
979979

980+
static int btrfs_load_block_group_dup(struct btrfs_fs_info *fs_info,
981+
struct btrfs_block_group *bg,
982+
struct map_lookup *map,
983+
struct zone_info *zone_info,
984+
unsigned long *active)
985+
{
986+
if ((map->type & BTRFS_BLOCK_GROUP_DATA) && !fs_info->stripe_root) {
987+
btrfs_err(fs_info, "zoned: data DUP profile needs raid-stripe-tree");
988+
return -EINVAL;
989+
}
990+
991+
bg->zone_capacity = min_not_zero(zone_info[0].capacity, zone_info[1].capacity);
992+
993+
if (zone_info[0].alloc_offset == WP_MISSING_DEV) {
994+
btrfs_err(fs_info,
995+
"zoned: cannot recover write pointer for zone %llu",
996+
zone_info[0].physical);
997+
return -EIO;
998+
}
999+
if (zone_info[1].alloc_offset == WP_MISSING_DEV) {
1000+
btrfs_err(fs_info,
1001+
"zoned: cannot recover write pointer for zone %llu",
1002+
zone_info[1].physical);
1003+
return -EIO;
1004+
}
1005+
if (zone_info[0].alloc_offset != zone_info[1].alloc_offset) {
1006+
btrfs_err(fs_info,
1007+
"zoned: write pointer offset mismatch of zones in DUP profile");
1008+
return -EIO;
1009+
}
1010+
1011+
if (test_bit(0, active) != test_bit(1, active)) {
1012+
return -EIO;
1013+
} else if (test_bit(0, active)) {
1014+
bg->zone_is_active = 1;
1015+
}
1016+
1017+
bg->alloc_offset = zone_info[0].alloc_offset;
1018+
return 0;
1019+
}
9801020

9811021
int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
9821022
struct btrfs_block_group *cache)
@@ -1067,6 +1107,8 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
10671107
ret = btrfs_load_block_group_single(fs_info, cache, &zone_info[0], active);
10681108
break;
10691109
case BTRFS_BLOCK_GROUP_DUP:
1110+
ret = btrfs_load_block_group_dup(fs_info, cache, map, zone_info, active);
1111+
break;
10701112
case BTRFS_BLOCK_GROUP_RAID1:
10711113
case BTRFS_BLOCK_GROUP_RAID1C3:
10721114
case BTRFS_BLOCK_GROUP_RAID1C4:

0 commit comments

Comments
 (0)