]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
btrfs: avoid starting new transaction when cleaning qgroup during subvolume drop
authorFilipe Manana <fdmanana@suse.com>
Tue, 21 Jan 2025 12:24:39 +0000 (12:24 +0000)
committerDavid Sterba <dsterba@suse.com>
Thu, 23 Jan 2025 21:34:17 +0000 (22:34 +0100)
At btrfs_qgroup_cleanup_dropped_subvolume() all we want to commit the
current transaction in order to have all the qgroup rfer/excl numbers up
to date. However we are using btrfs_start_transaction(), which joins the
current transaction if there is one that is not yet committing, but also
starts a new one if there is none or if the current one is already
committing (its state is >= TRANS_STATE_COMMIT_START). This later case
results in unnecessary IO, wasting time and a pointless rotation of the
backup roots in the super block.

So instead of using btrfs_start_transaction() followed by a
btrfs_commit_transaction(), use btrfs_commit_current_transaction() which
achieves our purpose and avoids starting and committing new transactions.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/qgroup.c

index aaf16019d829abefefbfa5169667b8b7295e8f94..f9d3766c809b4edd5d6266be7e93f2442448403d 100644 (file)
@@ -1880,11 +1880,7 @@ int btrfs_qgroup_cleanup_dropped_subvolume(struct btrfs_fs_info *fs_info, u64 su
         * Commit current transaction to make sure all the rfer/excl numbers
         * get updated.
         */
-       trans = btrfs_start_transaction(fs_info->quota_root, 0);
-       if (IS_ERR(trans))
-               return PTR_ERR(trans);
-
-       ret = btrfs_commit_transaction(trans);
+       ret = btrfs_commit_current_transaction(fs_info->quota_root);
        if (ret < 0)
                return ret;