Commit 1bfd4767 authored by Naohiro Aota's avatar Naohiro Aota Committed by David Sterba

btrfs: zoned: introduce btrfs_zoned_bg_is_full

Introduce a wrapper to check if all the space in a block group is
allocated or not.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent cf4f03c3
...@@ -3800,8 +3800,7 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group, ...@@ -3800,8 +3800,7 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
/* Check RO and no space case before trying to activate it */ /* Check RO and no space case before trying to activate it */
spin_lock(&block_group->lock); spin_lock(&block_group->lock);
if (block_group->ro || if (block_group->ro || btrfs_zoned_bg_is_full(block_group)) {
block_group->alloc_offset == block_group->zone_capacity) {
ret = 1; ret = 1;
/* /*
* May need to clear fs_info->{treelog,data_reloc}_bg. * May need to clear fs_info->{treelog,data_reloc}_bg.
......
...@@ -1836,7 +1836,7 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group) ...@@ -1836,7 +1836,7 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
} }
/* No space left */ /* No space left */
if (block_group->alloc_offset == block_group->zone_capacity) { if (btrfs_zoned_bg_is_full(block_group)) {
ret = false; ret = false;
goto out_unlock; goto out_unlock;
} }
......
...@@ -372,4 +372,10 @@ static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode) ...@@ -372,4 +372,10 @@ static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode)
mutex_unlock(&root->fs_info->zoned_data_reloc_io_lock); mutex_unlock(&root->fs_info->zoned_data_reloc_io_lock);
} }
static inline bool btrfs_zoned_bg_is_full(const struct btrfs_block_group *bg)
{
ASSERT(btrfs_is_zoned(bg->fs_info));
return (bg->alloc_offset == bg->zone_capacity);
}
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment