From 447bf2fb3741221a3d809dbd7d4ffd5adbbe8959 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 6 Oct 2021 23:54:13 +0200 Subject: [PATCH] btrfs-progs: zoned: factor out supported profiles to a helper The enumeration could get out of date, like fixed in previous commit. Create a helper that will hide the implementation details. Signed-off-by: David Sterba --- kernel-shared/zoned.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c index 6805e567..776576bc 100644 --- a/kernel-shared/zoned.c +++ b/kernel-shared/zoned.c @@ -808,6 +808,17 @@ out: return ret; } +static bool profile_supported(u64 flags) +{ + flags &= BTRFS_BLOCK_GROUP_PROFILE_MASK; + + /* SINGLE */ + if (flags == 0) + return true; + /* non-single profiles are not supported yet */ + return false; +} + int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info, struct btrfs_block_group *cache) { @@ -919,25 +930,13 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info, } } - switch (map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) { - case 0: /* single */ - cache->alloc_offset = alloc_offsets[0]; - break; - case BTRFS_BLOCK_GROUP_DUP: - case BTRFS_BLOCK_GROUP_RAID1: - case BTRFS_BLOCK_GROUP_RAID1C3: - case BTRFS_BLOCK_GROUP_RAID1C4: - case BTRFS_BLOCK_GROUP_RAID0: - case BTRFS_BLOCK_GROUP_RAID10: - case BTRFS_BLOCK_GROUP_RAID5: - case BTRFS_BLOCK_GROUP_RAID6: - /* non-single profiles are not supported yet */ - default: + if (!profile_supported(map->type)) { error("zoned: profile %s not yet supported", btrfs_group_profile_str(map->type)); ret = -EINVAL; goto out; } + cache->alloc_offset = alloc_offsets[0]; out: /* An extent is allocated after the write pointer */