]> git.hungrycats.org Git - linux/commit
btrfs: zoned: don't skip block groups with 100% zone unusable
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Wed, 21 Feb 2024 15:35:52 +0000 (07:35 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:11:48 +0000 (15:11 +0200)
commitddc278ed9e8f5e12d69df7bd4b7126cb82161519
treeff9244307cf2454d3416b6d150e73efb2cc892a7
parent3a25878a3378adce5d846300c9570f15aa7f7a80
btrfs: zoned: don't skip block groups with 100% zone unusable

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@vger.kernel.org # 6.1+
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/block-group.c