diff options
author | Naohiro Aota <naohiro.aota@wdc.com> | 2022-05-03 17:48:52 -0700 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-05-16 17:17:32 +0200 |
commit | 8b8a53998caefebfe5c8da7a74c2b601caf5dd48 (patch) | |
tree | 145d95377538e175df106ce9e6e9716ee860bd8b /fs/btrfs | |
parent | d70cbdda75da3f258118a558c087157e073229fb (diff) | |
download | linux-stable-8b8a53998caefebfe5c8da7a74c2b601caf5dd48.tar.gz linux-stable-8b8a53998caefebfe5c8da7a74c2b601caf5dd48.tar.bz2 linux-stable-8b8a53998caefebfe5c8da7a74c2b601caf5dd48.zip |
btrfs: zoned: finish block group when there are no more allocatable bytes left
Currently, btrfs_zone_finish_endio() finishes a block group only when the
written region reaches the end of the block group. We can also finish the
block group when no more allocation is possible.
Fixes: be1a1d7a5d24 ("btrfs: zoned: finish fully written block group")
CC: stable@vger.kernel.org # 5.16+
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/zoned.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index eb63b5ec3be8..cce46d6bb231 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -2021,6 +2021,7 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags) void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length) { struct btrfs_block_group *block_group; + u64 min_alloc_bytes; if (!btrfs_is_zoned(fs_info)) return; @@ -2028,7 +2029,15 @@ void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 len block_group = btrfs_lookup_block_group(fs_info, logical); ASSERT(block_group); - if (logical + length < block_group->start + block_group->zone_capacity) + /* No MIXED_BG on zoned btrfs. */ + if (block_group->flags & BTRFS_BLOCK_GROUP_DATA) + min_alloc_bytes = fs_info->sectorsize; + else + min_alloc_bytes = fs_info->nodesize; + + /* Bail out if we can allocate more data from this block group. */ + if (logical + length + min_alloc_bytes <= + block_group->start + block_group->zone_capacity) goto out; do_zone_finish(block_group, true); |