From: Filipe Manana Date: Thu, 20 Jul 2023 11:44:33 +0000 (+0100) Subject: btrfs: account block group tree when calculating global reserve size X-Git-Tag: v6.1.43~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cbec34d3021d47007a0334c634f7053dbaf93d02;p=thirdparty%2Fkernel%2Fstable.git btrfs: account block group tree when calculating global reserve size commit 8dbfc14fc736eb701089aff09645c3d4ad3decb1 upstream. When using the block group tree feature, this tree is a critical tree just like the extent, csum and free space trees, and just like them it uses the delayed refs block reserve. So take into account the block group tree, and its current size, when calculating the size for the global reserve. CC: stable@vger.kernel.org # 6.1+ Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c index 2044f1e186297..507b44d18572d 100644 --- a/fs/btrfs/block-rsv.c +++ b/fs/btrfs/block-rsv.c @@ -377,6 +377,11 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info) } read_unlock(&fs_info->global_root_lock); + if (btrfs_fs_compat_ro(fs_info, BLOCK_GROUP_TREE)) { + num_bytes += btrfs_root_used(&fs_info->block_group_root->root_item); + min_items++; + } + /* * But we also want to reserve enough space so we can do the fallback * global reserve for an unlink, which is an additional 5 items (see the