Skip to content

Commit 8b0d6d1

Browse files
fdmananagregkh
authored andcommitted
btrfs: fix leak of qgroup extent records after transaction abort
[ Upstream commit fb33eb2 ] Qgroup extent records are created when delayed ref heads are created and then released after accounting extents at btrfs_qgroup_account_extents(), called during the transaction commit path. If a transaction is aborted we free the qgroup records by calling btrfs_qgroup_destroy_extent_records() at btrfs_destroy_delayed_refs(), unless we don't have delayed references. We are incorrectly assuming that no delayed references means we don't have qgroup extents records. We can currently have no delayed references because we ran them all during a transaction commit and the transaction was aborted after that due to some error in the commit path. So fix this by ensuring we btrfs_qgroup_destroy_extent_records() at btrfs_destroy_delayed_refs() even if we don't have any delayed references. Reported-by: [email protected] Link: https://lore.kernel.org/linux-btrfs/[email protected]/ Fixes: 81f7eb0 ("btrfs: destroy qgroup extent records on transaction abort") CC: [email protected] # 6.1+ Reviewed-by: Josef Bacik <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b1a5d3f commit 8b0d6d1

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

fs/btrfs/disk-io.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4943,18 +4943,10 @@ static void btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
49434943
struct btrfs_fs_info *fs_info)
49444944
{
49454945
struct rb_node *node;
4946-
struct btrfs_delayed_ref_root *delayed_refs;
4946+
struct btrfs_delayed_ref_root *delayed_refs = &trans->delayed_refs;
49474947
struct btrfs_delayed_ref_node *ref;
49484948

4949-
delayed_refs = &trans->delayed_refs;
4950-
49514949
spin_lock(&delayed_refs->lock);
4952-
if (atomic_read(&delayed_refs->num_entries) == 0) {
4953-
spin_unlock(&delayed_refs->lock);
4954-
btrfs_debug(fs_info, "delayed_refs has NO entry");
4955-
return;
4956-
}
4957-
49584950
while ((node = rb_first_cached(&delayed_refs->href_root)) != NULL) {
49594951
struct btrfs_delayed_ref_head *head;
49604952
struct rb_node *n;

0 commit comments

Comments
 (0)