]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: simplify how first hit is passed to __btrfs_abort_transaction()
authorDavid Sterba <dsterba@suse.com>
Thu, 7 May 2026 17:59:32 +0000 (19:59 +0200)
committerFilipe Manana <fdmanana@suse.com>
Tue, 9 Jun 2026 10:49:25 +0000 (11:49 +0100)
commit513528a286e0807968fb2baf1db4e6ad5a49e724
treec3330c260b33a49cf6ba6ee17e4c7e861b7ff8d7
parente6c249adb7217a20534e0583a82ee28251c65dc4
btrfs: simplify how first hit is passed to __btrfs_abort_transaction()

Optimize the btrfs_abort_transaction() for size as it (by our
convention) must be put right after the error condition is detected.
The exact file:line is reported so there's a portion that must be
inlined. As this is cold code it bloats functions. In previous patch
"btrfs: move transaction abort message to __btrfs_abort_transaction()"
the error message was moved to the common helper, saving like 20KiB of
btrfs.ko and several instructions per call site and some stack space.

There's little left to be optimized, we need to keep the atomic
test_and_set_bit() and to convey that as 'first hit' to
__btrfs_abort_transaction().

Right now it's a bool, which takes 8 bytes on stack for each call but
it's 1 bit of information. We can encode that to some of the other
parameters.

For that let's use the 'error' parameter, by convention it's negative
errno so we can reliably detect if it's the first hit or a later error.
Also the negation is usually implemented by a single instruction (NEG on
x86_64) so the resulting object code is kept short.

This reduces btrfs.ko by 8K and stack in several functions by 8 bytes.

Cumulative effect with the other commit is -30K of btrfs.ko. While the
encoding is an implementation detail, it's contained within the API.
Making the transaction abort calls very light is desired.

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/transaction.c
fs/btrfs/transaction.h