Skip to content

Commit 8b8a539

Browse files
naotakdave
authored andcommitted
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: be1a1d7 ("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>
1 parent d70cbdd commit 8b8a539

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

fs/btrfs/zoned.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,14 +2021,23 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
20212021
void btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 length)
20222022
{
20232023
struct btrfs_block_group *block_group;
2024+
u64 min_alloc_bytes;
20242025

20252026
if (!btrfs_is_zoned(fs_info))
20262027
return;
20272028

20282029
block_group = btrfs_lookup_block_group(fs_info, logical);
20292030
ASSERT(block_group);
20302031

2031-
if (logical + length < block_group->start + block_group->zone_capacity)
2032+
/* No MIXED_BG on zoned btrfs. */
2033+
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA)
2034+
min_alloc_bytes = fs_info->sectorsize;
2035+
else
2036+
min_alloc_bytes = fs_info->nodesize;
2037+
2038+
/* Bail out if we can allocate more data from this block group. */
2039+
if (logical + length + min_alloc_bytes <=
2040+
block_group->start + block_group->zone_capacity)
20322041
goto out;
20332042

20342043
do_zone_finish(block_group, true);

0 commit comments

Comments
 (0)