]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: move transaction abort message to __btrfs_abort_transaction()
authorDavid Sterba <dsterba@suse.com>
Wed, 29 Apr 2026 14:32:53 +0000 (16:32 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:31 +0000 (15:53 +0200)
The btrfs_abort_transaction() is called at the location where we want to
report the abort. It must be a macro so we get the correct line and
stack trace. This inlines the necessary code and the rest is pushed to
__btrfs_abort_transaction().

There's a possibility to reduce the inlined code if we move the message
to the helper function as well, without loss of information. The
difference is only that the WARN will not print it inside the stack
report but after:

  --[ cut here ]--
  WARNING: fs/btrfs/transaction.c:2045 at btrfs_commit_transaction+0xa21/0xd30 [btrfs], CPU#11: bonnie++/3377975
  ...
  --[ end trace ] --
  BTRFS error (device dm-0 state A): Transaction aborted (error -28)

While previously there would be one more line like:

  --[ cut here ]--
  BTRFS: Transaction aborted (error -28)
  WARNING: fs/btrfs/transaction.c:2045 at btrfs_commit_transaction+0xa21/0xd30 [btrfs], CPU#11: bonnie++/3377975
  ...
  --[ end trace ] --

This removes about 20KiB of btrfs.ko on a release config.

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

index 194f581b36f36ed0925ded837d32fa387523a429..0fd596e2c65b84b6dc681d81cc9f7629ec466394 100644 (file)
@@ -2731,8 +2731,12 @@ void __cold __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
 
        WRITE_ONCE(trans->aborted, error);
        WRITE_ONCE(trans->transaction->aborted, error);
-       if (first_hit && error == -ENOSPC)
-               btrfs_dump_space_info_for_trans_abort(fs_info);
+       if (first_hit) {
+               btrfs_err(fs_info, "Transaction %llu aborted (error %d)",
+                         trans->transid, error);
+               if (error == -ENOSPC)
+                       btrfs_dump_space_info_for_trans_abort(fs_info);
+       }
        /* Wake up anybody who may be waiting on this transaction */
        wake_up(&fs_info->transaction_wait);
        wake_up(&fs_info->transaction_blocked_wait);
index 7d70fe486758706e303ba2771da24f726c70354f..f1cb05460cec1f13be558f17ab10f2750d3de078 100644 (file)
@@ -253,16 +253,7 @@ do {                                                               \
        if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED,     \
                        &((trans)->fs_info->fs_state))) {       \
                __first = true;                                 \
-               if (WARN(btrfs_abort_should_print_stack(error), \
-                       KERN_ERR                                \
-                       "BTRFS: Transaction aborted (error %d)\n",      \
-                       (error))) {                                     \
-                       /* Stack trace printed. */                      \
-               } else {                                                \
-                       btrfs_err((trans)->fs_info,                     \
-                                 "Transaction aborted (error %d)",     \
-                                 (error));                     \
-               }                                               \
+               WARN_ON(btrfs_abort_should_print_stack(error)); \
        }                                                       \
        __btrfs_abort_transaction((trans), __func__,            \
                                  __LINE__, (error), __first);  \