summaryrefslogtreecommitdiff
path: root/fs/btrfs/block-group.c
diff options
context:
space:
mode:
authorBoris Burkov <boris@bur.io>2022-12-16 03:06:35 +0300
committerDavid Sterba <dsterba@suse.com>2023-02-13 19:50:34 +0300
commitcb0922f264643f03b04352f7a04abb913c609369 (patch)
tree2fbe7804f1e87b4e080b5c5a83575cd8011642e4 /fs/btrfs/block-group.c
parentc7eec3d9aa955cbd00470f874f34bdba946bd101 (diff)
downloadlinux-cb0922f264643f03b04352f7a04abb913c609369.tar.xz
btrfs: don't use size classes for zoned file systems
When a file system has ZNS devices which are constrained by a maximum number of active block groups, then not being able to use all the block groups for every allocation is not ideal, and could cause us to loop a ton with mixed size allocations. In general, since zoned doesn't write into gaps behind where block groups are writing, it is not susceptible to the same sort of fragmentation that size classes are designed to solve, so we can skip size classes for zoned file systems in general, even though there would probably be no harm for SMR devices. Signed-off-by: Boris Burkov <boris@bur.io> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/block-group.c')
-rw-r--r--fs/btrfs/block-group.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 8a711b429515..45ccb25c5b1f 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -665,7 +665,7 @@ static int load_block_group_size_class(struct btrfs_caching_control *caching_ctl
enum btrfs_block_group_size_class size_class = BTRFS_BG_SZ_NONE;
int ret;
- if (!btrfs_is_block_group_data_only(block_group))
+ if (!btrfs_block_group_should_use_size_class(block_group))
return 0;
for (i = 0; i < 5; ++i) {
@@ -3597,7 +3597,7 @@ int btrfs_add_reserved_bytes(struct btrfs_block_group *cache,
goto out;
}
- if (btrfs_is_block_group_data_only(cache)) {
+ if (btrfs_block_group_should_use_size_class(cache)) {
size_class = btrfs_calc_block_group_size_class(num_bytes);
ret = btrfs_use_block_group_size_class(cache, size_class, force_wrong_size_class);
if (ret)
@@ -4439,3 +4439,12 @@ int btrfs_use_block_group_size_class(struct btrfs_block_group *bg,
return 0;
}
+
+bool btrfs_block_group_should_use_size_class(struct btrfs_block_group *bg)
+{
+ if (btrfs_is_zoned(bg->fs_info))
+ return false;
+ if (!btrfs_is_block_group_data_only(bg))
+ return false;
+ return true;
+}