]> git.hungrycats.org Git - linux/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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:42:26 +0000 (14:42 +0200)
[ Upstream commit 1bfd476754a2d63f899ef9c3e253b17766b8fb73 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/extent-tree.c
fs/btrfs/zoned.c
fs/btrfs/zoned.h

index bdebd77f31b4d8a739d63ab55e36945308becc35..56185541e1886d637e1d62b06c44ca9490206949 100644 (file)
@@ -3803,8 +3803,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 0a6a3d6f5af78a016a5aed071656168b6cc3d1ca..17068179728346f887c8efb0db3a41988f85f319 100644 (file)
@@ -1859,7 +1859,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 199b69670fa25e4d74aa924fa5fa2736725df02d..0740458894ac5b240ee41667ac1df05214e1e265 100644 (file)
@@ -384,4 +384,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