This is a note to let you know that I've just added the patch titled btrfs: qgroup: correctly model root qgroup rsv in convert to the 5.10-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-qgroup-correctly-model-root-qgroup-rsv-in-convert.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 141fb8cd206ace23c02cd2791c6da52c1d77d42a Mon Sep 17 00:00:00 2001 From: Boris Burkov <boris@xxxxxx> Date: Tue, 19 Mar 2024 10:54:22 -0700 Subject: btrfs: qgroup: correctly model root qgroup rsv in convert From: Boris Burkov <boris@xxxxxx> commit 141fb8cd206ace23c02cd2791c6da52c1d77d42a upstream. We use add_root_meta_rsv and sub_root_meta_rsv to track prealloc and pertrans reservations for subvolumes when quotas are enabled. The convert function does not properly increment pertrans after decrementing prealloc, so the count is not accurate. Note: we check that the fs is not read-only to mirror the logic in qgroup_convert_meta, which checks that before adding to the pertrans rsv. Fixes: 8287475a2055 ("btrfs: qgroup: Use root::qgroup_meta_rsv_* to record qgroup meta reserved space") CC: stable@xxxxxxxxxxxxxxx # 6.1+ Reviewed-by: Qu Wenruo <wqu@xxxxxxxx> Signed-off-by: Boris Burkov <boris@xxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/qgroup.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -4114,6 +4114,8 @@ void btrfs_qgroup_convert_reserved_meta( BTRFS_QGROUP_RSV_META_PREALLOC); trace_qgroup_meta_convert(root, num_bytes); qgroup_convert_meta(fs_info, root->root_key.objectid, num_bytes); + if (!sb_rdonly(fs_info->sb)) + add_root_meta_rsv(root, num_bytes, BTRFS_QGROUP_RSV_META_PERTRANS); } /* Patches currently in stable-queue which might be from boris@xxxxxx are queue-5.10/btrfs-qgroup-correctly-model-root-qgroup-rsv-in-convert.patch