Introduce a wrapper to check if all the space in a block group is
allocated or not.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
 
        /* Check RO and no space case before trying to activate it */
        spin_lock(&block_group->lock);
-       if (block_group->ro ||
-           block_group->alloc_offset == block_group->zone_capacity) {
+       if (block_group->ro || btrfs_zoned_bg_is_full(block_group)) {
                ret = 1;
                /*
                 * May need to clear fs_info->{treelog,data_reloc}_bg.
 
        }
 
        /* No space left */
-       if (block_group->alloc_offset == block_group->zone_capacity) {
+       if (btrfs_zoned_bg_is_full(block_group)) {
                ret = false;
                goto out_unlock;
        }
 
                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