]> git.itanic.dy.fi Git - linux-stable/commit
btrfs: qgroup: convert PREALLOC to PERTRANS after record_root_in_trans
authorBoris Burkov <boris@bur.io>
Thu, 21 Mar 2024 17:18:39 +0000 (10:18 -0700)
committerDavid Sterba <dsterba@suse.com>
Tue, 2 Apr 2024 17:18:47 +0000 (19:18 +0200)
commit211de93367304ab395357f8cb12568a4d1e20701
tree29dcf31fd1f377ba03d4dbe6b80479da260dc0bf
parent71537e35c324ea6fbd68377a4f26bb93a831ae35
btrfs: qgroup: convert PREALLOC to PERTRANS after record_root_in_trans

The transaction is only able to free PERTRANS reservations for a root
once that root has been recorded with the TRANS tag on the roots radix
tree. Therefore, until we are sure that this root will get tagged, it
isn't safe to convert. Generally, this is not an issue as *some*
transaction will likely tag the root before long and this reservation
will get freed in that transaction, but technically it could stick
around until unmount and result in a warning about leaked metadata
reservation space.

This path is most exercised by running the generic/269 fstest with
CONFIG_BTRFS_DEBUG.

Fixes: a6496849671a ("btrfs: fix start transaction qgroup rsv double free")
CC: stable@vger.kernel.org # 6.6+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/transaction.c