]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: zoned: introduce btrfs_zoned_bg_is_full
authorNaohiro Aota <naohiro.aota@wdc.com>
Wed, 4 May 2022 00:48:50 +0000 (17:48 -0700)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:17:32 +0000 (17:17 +0200)
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>
fs/btrfs/extent-tree.c
fs/btrfs/zoned.c
fs/btrfs/zoned.h

index 8ef4aa5a46d65f5a5773c9aeb670b95d638731d4..fb367689d9d20e6b7c5e1c6e0a4298873735bf52 100644 (file)
@@ -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 */
        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.
index 6e91022ae9f6996ab85c9359ca59344a71c791ae..cc0c5dd5a901b889266d4ef8051b6c87c264a920 100644 (file)
@@ -1836,7 +1836,7 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
        }
 
        /* 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;
        }
index de923fc8449d36ccb3132140b322d01862701678..7178bafda469c97d24fe273860cd9e53bcecad23 100644 (file)
@@ -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);
 }
 
+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