]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: avoid starting new transaction and commit in relocate_block_group()
authorFilipe Manana <fdmanana@suse.com>
Mon, 9 Feb 2026 19:45:06 +0000 (19:45 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:55:55 +0000 (18:55 +0200)
commit0eb6c12491ca44140a5facdaee3c8cb6f41202d2
treefd76a52d00b4b4af5fd86e7cc2cb4efb586ed1bd
parent90b7d4c415b2992125b8ff8fcd3191b14047fb7f
btrfs: avoid starting new transaction and commit in relocate_block_group()

We join a transaction with the goal of catching the current transaction
and then commit it to get rid of pinned extents and reclaim free space,
but a join can create a new transaction if there isn't any running, and if
right before we did the join the current transaction happened to be
committed by someone else (like the transaction kthread for example),
we end up starting and committing a new transaction, causing rotation of
the super block backup roots besides extra and useless IO.

So instead of doing a transaction join followed by a commit, use the
helper btrfs_commit_current_transaction() which ensures no transaction is
created if there isn't any running.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c