Skip to content

Commit 1bfd476

Browse files
naotakdave
authored andcommitted
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: 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>
1 parent cf4f03c commit 1bfd476

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

fs/btrfs/extent-tree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3800,8 +3800,7 @@ static int do_allocation_zoned(struct btrfs_block_group *block_group,
38003800

38013801
/* Check RO and no space case before trying to activate it */
38023802
spin_lock(&block_group->lock);
3803-
if (block_group->ro ||
3804-
block_group->alloc_offset == block_group->zone_capacity) {
3803+
if (block_group->ro || btrfs_zoned_bg_is_full(block_group)) {
38053804
ret = 1;
38063805
/*
38073806
* May need to clear fs_info->{treelog,data_reloc}_bg.

fs/btrfs/zoned.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
18361836
}
18371837

18381838
/* No space left */
1839-
if (block_group->alloc_offset == block_group->zone_capacity) {
1839+
if (btrfs_zoned_bg_is_full(block_group)) {
18401840
ret = false;
18411841
goto out_unlock;
18421842
}

fs/btrfs/zoned.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,4 +372,10 @@ static inline void btrfs_zoned_data_reloc_unlock(struct btrfs_inode *inode)
372372
mutex_unlock(&root->fs_info->zoned_data_reloc_io_lock);
373373
}
374374

375+
static inline bool btrfs_zoned_bg_is_full(const struct btrfs_block_group *bg)
376+
{
377+
ASSERT(btrfs_is_zoned(bg->fs_info));
378+
return (bg->alloc_offset == bg->zone_capacity);
379+
}
380+
375381
#endif

0 commit comments

Comments
 (0)