Message ID | 11de06f6243f4f048d19f105a170cbd6f8e5f4c3.1739756953.git.naohiro.aota@wdc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | btrfs-progs: zoned: support zone capacity and | expand |
On 17.02.25 03:39, Naohiro Aota wrote: > - /* SINGLE profile case. */ > - cache->alloc_offset = zone_info[0].alloc_offset; > - cache->zone_capacity = zone_info[0].capacity; > - cache->zone_is_active = test_bit(0, active); > + > + profile = map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK; > + switch (profile) { > + case 0: /* single */ > + ret = btrfs_load_block_group_single(fs_info, cache, &zone_info[0], active); > + break; > + case BTRFS_BLOCK_GROUP_RAID5: > + case BTRFS_BLOCK_GROUP_RAID6: > + default: > + error("zoned: profile %s not yet supported", > + btrfs_bg_type_to_raid_name(map->type)); > + ret = -EINVAL; > + goto out; > + } The above is missing RAID0/1/10. Which on a non-experimental build should also error out. I see patch 9 is adding RAID1 but I think this patch needs to add the cases as well and error out (for now).
On 17.02.25 18:13, Johannes Thumshirn wrote: > On 17.02.25 03:39, Naohiro Aota wrote: >> - /* SINGLE profile case. */ >> - cache->alloc_offset = zone_info[0].alloc_offset; >> - cache->zone_capacity = zone_info[0].capacity; >> - cache->zone_is_active = test_bit(0, active); >> + >> + profile = map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK; >> + switch (profile) { >> + case 0: /* single */ >> + ret = btrfs_load_block_group_single(fs_info, cache, &zone_info[0], active); >> + break; >> + case BTRFS_BLOCK_GROUP_RAID5: >> + case BTRFS_BLOCK_GROUP_RAID6: >> + default: >> + error("zoned: profile %s not yet supported", >> + btrfs_bg_type_to_raid_name(map->type)); >> + ret = -EINVAL; >> + goto out; >> + } > > The above is missing RAID0/1/10. Which on a non-experimental build > should also error out. I see patch 9 is adding RAID1 but I think this > patch needs to add the cases as well and error out (for now). > And DUP obviously as well sorry.
diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c index 4045cf0d2b98..3bc7d6ba1924 100644 --- a/kernel-shared/zoned.c +++ b/kernel-shared/zoned.c @@ -958,6 +958,26 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx, return 0; } +static int btrfs_load_block_group_single(struct btrfs_fs_info *fs_info, + struct btrfs_block_group *bg, + struct zone_info *info, + unsigned long *active) +{ + if (info->alloc_offset == WP_MISSING_DEV) { + btrfs_err(fs_info, + "zoned: cannot recover write pointer for zone %llu", + info->physical); + return -EIO; + } + + bg->alloc_offset = info->alloc_offset; + bg->zone_capacity = info->capacity; + if (test_bit(0, active)) + bg->zone_is_active = 1; + return 0; +} + + int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info, struct btrfs_block_group *cache) { @@ -972,6 +992,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info, int i; u64 last_alloc = 0; u32 num_conventional = 0; + u64 profile; if (!btrfs_is_zoned(fs_info)) return 0; @@ -1039,10 +1060,20 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info, ret = -EINVAL; goto out; } - /* SINGLE profile case. */ - cache->alloc_offset = zone_info[0].alloc_offset; - cache->zone_capacity = zone_info[0].capacity; - cache->zone_is_active = test_bit(0, active); + + profile = map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK; + switch (profile) { + case 0: /* single */ + ret = btrfs_load_block_group_single(fs_info, cache, &zone_info[0], active); + break; + case BTRFS_BLOCK_GROUP_RAID5: + case BTRFS_BLOCK_GROUP_RAID6: + default: + error("zoned: profile %s not yet supported", + btrfs_bg_type_to_raid_name(map->type)); + ret = -EINVAL; + goto out; + } out: /* An extent is allocated after the write pointer */
Currently, the userland tool only considers the SINGLE profile, which make it fail when a DUP block group is created over one conventional zone and one sequential required zone. Before adding the other profiles support, let's factor out per-profile code (actually, SINGLE only) into functions just like as the kernel side. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- kernel-shared/zoned.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-)