]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Mar 2025 19:54:14 +0000 (12:54 -0700)
commitfb51a7209398054c88b8750937ebbac4931bb0d2
tree918e1ad537b08f7ad922e301b520321024ff4932
parentccdec7ea9a3dd936d03da70f4a07d0fab8e34434
btrfs: avoid starting new transaction when cleaning qgroup during subvolume drop

[ Upstream commit fdef89ce6fada462aef9cb90a140c93c8c209f0f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/qgroup.c