Skip to content

Commit 6a8ebc7

Browse files
naotakdave
authored andcommitted
btrfs: zoned: no longer count fresh BG region as zone unusable
Now that we switched to write time activation, we no longer need to (and must not) count the fresh region as zone unusable. This commit is similar to revert of commit fa2068d ("btrfs: zoned: count fresh BG region as zone unusable"). Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 13bb483 commit 6a8ebc7

2 files changed

Lines changed: 4 additions & 30 deletions

File tree

fs/btrfs/free-space-cache.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,13 +2704,8 @@ static int __btrfs_add_free_space_zoned(struct btrfs_block_group *block_group,
27042704
bg_reclaim_threshold = READ_ONCE(sinfo->bg_reclaim_threshold);
27052705

27062706
spin_lock(&ctl->tree_lock);
2707-
/* Count initial region as zone_unusable until it gets activated. */
27082707
if (!used)
27092708
to_free = size;
2710-
else if (initial &&
2711-
test_bit(BTRFS_FS_ACTIVE_ZONE_TRACKING, &block_group->fs_info->flags) &&
2712-
(block_group->flags & (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_SYSTEM)))
2713-
to_free = 0;
27142709
else if (initial)
27152710
to_free = block_group->zone_capacity;
27162711
else if (offset >= block_group->alloc_offset)
@@ -2738,8 +2733,7 @@ static int __btrfs_add_free_space_zoned(struct btrfs_block_group *block_group,
27382733
reclaimable_unusable = block_group->zone_unusable -
27392734
(block_group->length - block_group->zone_capacity);
27402735
/* All the region is now unusable. Mark it as unused and reclaim */
2741-
if (block_group->zone_unusable == block_group->length &&
2742-
block_group->alloc_offset) {
2736+
if (block_group->zone_unusable == block_group->length) {
27432737
btrfs_mark_bg_unused(block_group);
27442738
} else if (bg_reclaim_threshold &&
27452739
reclaimable_unusable >=

fs/btrfs/zoned.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,19 +1586,9 @@ void btrfs_calc_zone_unusable(struct btrfs_block_group *cache)
15861586
return;
15871587

15881588
WARN_ON(cache->bytes_super != 0);
1589-
1590-
/* Check for block groups never get activated */
1591-
if (test_bit(BTRFS_FS_ACTIVE_ZONE_TRACKING, &cache->fs_info->flags) &&
1592-
cache->flags & (BTRFS_BLOCK_GROUP_METADATA | BTRFS_BLOCK_GROUP_SYSTEM) &&
1593-
!test_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &cache->runtime_flags) &&
1594-
cache->alloc_offset == 0) {
1595-
unusable = cache->length;
1596-
free = 0;
1597-
} else {
1598-
unusable = (cache->alloc_offset - cache->used) +
1599-
(cache->length - cache->zone_capacity);
1600-
free = cache->zone_capacity - cache->alloc_offset;
1601-
}
1589+
unusable = (cache->alloc_offset - cache->used) +
1590+
(cache->length - cache->zone_capacity);
1591+
free = cache->zone_capacity - cache->alloc_offset;
16021592

16031593
/* We only need ->free_space in ALLOC_SEQ block groups */
16041594
cache->cached = BTRFS_CACHE_FINISHED;
@@ -1962,7 +1952,6 @@ int btrfs_sync_zone_write_pointer(struct btrfs_device *tgt_dev, u64 logical,
19621952
bool btrfs_zone_activate(struct btrfs_block_group *block_group)
19631953
{
19641954
struct btrfs_fs_info *fs_info = block_group->fs_info;
1965-
struct btrfs_space_info *space_info = block_group->space_info;
19661955
struct map_lookup *map;
19671956
struct btrfs_device *device;
19681957
u64 physical;
@@ -1975,7 +1964,6 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
19751964

19761965
map = block_group->physical_map;
19771966

1978-
spin_lock(&space_info->lock);
19791967
spin_lock(&block_group->lock);
19801968
if (test_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &block_group->runtime_flags)) {
19811969
ret = true;
@@ -2025,14 +2013,7 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
20252013

20262014
/* Successfully activated all the zones */
20272015
set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &block_group->runtime_flags);
2028-
WARN_ON(block_group->alloc_offset != 0);
2029-
if (block_group->zone_unusable == block_group->length) {
2030-
block_group->zone_unusable = block_group->length - block_group->zone_capacity;
2031-
space_info->bytes_zone_unusable -= block_group->zone_capacity;
2032-
}
20332016
spin_unlock(&block_group->lock);
2034-
btrfs_try_granting_tickets(fs_info, space_info);
2035-
spin_unlock(&space_info->lock);
20362017

20372018
/* For the active block group list */
20382019
btrfs_get_block_group(block_group);
@@ -2045,7 +2026,6 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
20452026

20462027
out_unlock:
20472028
spin_unlock(&block_group->lock);
2048-
spin_unlock(&space_info->lock);
20492029
return ret;
20502030
}
20512031

0 commit comments

Comments
 (0)