btrfs: free PERTRANS at the end of cleanup_transaction()
authorBoris Burkov <boris@bur.io>
Tue, 26 Mar 2024 18:17:12 +0000 (11:17 -0700)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 May 2024 19:31:02 +0000 (21:31 +0200)
Some of the operations after the free might convert more PERTRANS
metadata. Do the freeing as late as possible to eliminate a source of
leaked PERTRANS metadata.

This helps with the pass rate of generic/269 and generic/475.

Reviewed-by: Qu Wenruo <qwu@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c

index 3df5477d48a81ef463e605f17affa97fdb33a2be..5a35c2c0bbc94d2cbfcdc48345c211c0b07ee5ae 100644 (file)
@@ -4844,14 +4844,10 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
        cur_trans->state = TRANS_STATE_UNBLOCKED;
        wake_up(&fs_info->transaction_wait);
 
-       btrfs_destroy_delayed_inodes(fs_info);
-
        btrfs_destroy_marked_extents(fs_info, &cur_trans->dirty_pages,
                                     EXTENT_DIRTY);
        btrfs_destroy_pinned_extent(fs_info, &cur_trans->pinned_extents);
 
-       btrfs_free_all_qgroup_pertrans(fs_info);
-
        cur_trans->state =TRANS_STATE_COMPLETED;
        wake_up(&cur_trans->commit_wait);
 }
@@ -4904,6 +4900,7 @@ static int btrfs_cleanup_transaction(struct btrfs_fs_info *fs_info)
        btrfs_assert_delayed_root_empty(fs_info);
        btrfs_destroy_all_delalloc_inodes(fs_info);
        btrfs_drop_all_logs(fs_info);
+       btrfs_free_all_qgroup_pertrans(fs_info);
        mutex_unlock(&fs_info->transaction_kthread_mutex);
 
        return 0;