summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>2025-12-15 11:38:18 +0100
committerDavid Sterba <dsterba@suse.com>2026-02-03 07:49:10 +0100
commit4273db18a84ea3042b67864939e69b79eca50235 (patch)
tree025afd113de1b83e8f66eb3346bbee2e0b5a9ddd
parent3dcdcb7177632559e9392e755636a60e33e867b0 (diff)
btrfs: zoned: re-flow prepare_allocation_zoned()
Re-flow prepare allocation zoned to make it a bit more readable by returning early and removing unnecessary indentations. This patch does not change any functionality. Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/extent-tree.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3b840a4fdf1c..1dcd69fe97ed 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4284,36 +4284,43 @@ static int prepare_allocation_zoned(struct btrfs_fs_info *fs_info,
struct find_free_extent_ctl *ffe_ctl,
struct btrfs_space_info *space_info)
{
+ struct btrfs_block_group *block_group;
+
if (ffe_ctl->for_treelog) {
spin_lock(&fs_info->treelog_bg_lock);
if (fs_info->treelog_bg)
ffe_ctl->hint_byte = fs_info->treelog_bg;
spin_unlock(&fs_info->treelog_bg_lock);
- } else if (ffe_ctl->for_data_reloc) {
+ return 0;
+ }
+
+ if (ffe_ctl->for_data_reloc) {
spin_lock(&fs_info->relocation_bg_lock);
if (fs_info->data_reloc_bg)
ffe_ctl->hint_byte = fs_info->data_reloc_bg;
spin_unlock(&fs_info->relocation_bg_lock);
- } else if (ffe_ctl->flags & BTRFS_BLOCK_GROUP_DATA) {
- struct btrfs_block_group *block_group;
+ return 0;
+ }
- spin_lock(&fs_info->zone_active_bgs_lock);
- list_for_each_entry(block_group, &fs_info->zone_active_bgs, active_bg_list) {
- /*
- * No lock is OK here because avail is monotonically
- * decreasing, and this is just a hint.
- */
- u64 avail = block_group->zone_capacity - block_group->alloc_offset;
+ if (!(ffe_ctl->flags & BTRFS_BLOCK_GROUP_DATA))
+ return 0;
- if (block_group_bits(block_group, ffe_ctl->flags) &&
- block_group->space_info == space_info &&
- avail >= ffe_ctl->num_bytes) {
- ffe_ctl->hint_byte = block_group->start;
- break;
- }
+ spin_lock(&fs_info->zone_active_bgs_lock);
+ list_for_each_entry(block_group, &fs_info->zone_active_bgs, active_bg_list) {
+ /*
+ * No lock is OK here because avail is monotonically
+ * decreasing, and this is just a hint.
+ */
+ u64 avail = block_group->zone_capacity - block_group->alloc_offset;
+
+ if (block_group_bits(block_group, ffe_ctl->flags) &&
+ block_group->space_info == space_info &&
+ avail >= ffe_ctl->num_bytes) {
+ ffe_ctl->hint_byte = block_group->start;
+ break;
}
- spin_unlock(&fs_info->zone_active_bgs_lock);
}
+ spin_unlock(&fs_info->zone_active_bgs_lock);
return 0;
}