This is a note to let you know that I've just added the patch titled btrfs: zoned: don't skip block groups with 100% zone unusable to the 6.8-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-zoned-don-t-skip-block-groups-with-100-zone-unusable.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From a8b70c7f8600bc77d03c0b032c0662259b9e615e Mon Sep 17 00:00:00 2001 From: Johannes Thumshirn <johannes.thumshirn@xxxxxxx> Date: Wed, 21 Feb 2024 07:35:52 -0800 Subject: btrfs: zoned: don't skip block groups with 100% zone unusable From: Johannes Thumshirn <johannes.thumshirn@xxxxxxx> commit a8b70c7f8600bc77d03c0b032c0662259b9e615e upstream. Commit f4a9f219411f ("btrfs: do not delete unused block group if it may be used soon") changed the behaviour of deleting unused block-groups on zoned filesystems. Starting with this commit, we're using btrfs_space_info_used() to calculate the number of used bytes in a space_info. But btrfs_space_info_used() also accounts btrfs_space_info::bytes_zone_unusable as used bytes. So if a block group is 100% zone_unusable it is skipped from the deletion step. In order not to skip fully zone_unusable block-groups, also check if the block-group has bytes left that can be used on a zoned filesystem. Fixes: f4a9f219411f ("btrfs: do not delete unused block group if it may be used soon") CC: stable@xxxxxxxxxxxxxxx # 6.1+ Reviewed-by: Filipe Manana <fdmanana@xxxxxxxx> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx> Reviewed-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/block-group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -1550,7 +1550,8 @@ void btrfs_delete_unused_bgs(struct btrf * needing to allocate extents from the block group. */ used = btrfs_space_info_used(space_info, true); - if (space_info->total_bytes - block_group->length < used) { + if (space_info->total_bytes - block_group->length < used && + block_group->zone_unusable < block_group->length) { /* * Add a reference for the list, compensate for the ref * drop under the "next" label for the Patches currently in stable-queue which might be from johannes.thumshirn@xxxxxxx are queue-6.8/btrfs-add-helpers-to-get-fs_info-from-page-folio-poi.patch queue-6.8/btrfs-add-helper-to-get-fs_info-from-struct-inode-po.patch queue-6.8/btrfs-zoned-fix-use-after-free-in-do_zone_finish.patch queue-6.8/btrfs-add-helpers-to-get-inode-from-page-folio-point.patch queue-6.8/btrfs-zoned-don-t-skip-block-groups-with-100-zone-unusable.patch queue-6.8/btrfs-zoned-use-zone-aware-sb-location-for-scrub.patch queue-6.8/btrfs-add-set_folio_extent_mapped-helper.patch