btrfs: move abort_should_print_stack() to transaction.h
authorFilipe Manana <fdmanana@suse.com>
Mon, 16 Dec 2024 11:26:35 +0000 (11:26 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 13 Jan 2025 13:53:17 +0000 (14:53 +0100)
The function abort_should_print_stack() is declared in transaction.h but
its definition is in ctree.c, which doesn't make sense since ctree.c is
the btree implementation and the function is related to the transaction
code. Move its definition into transaction.h as an inline function since
it's a very short and trivial function, and also add the 'btrfs_' prefix
into its name.

This change also reduces the module size.

Before this change:

  $ size fs/btrfs/btrfs.ko
     text    data     bss     dec     hex filename
  1783148  161137   16920 1961205  1decf5 fs/btrfs/btrfs.ko

After this change:

  $ size fs/btrfs/btrfs.ko
     text    data     bss     dec     hex filename
  1782126  161045   16920 1960091  1de89b fs/btrfs/btrfs.ko

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c
fs/btrfs/transaction.h

index 185985a337b30f5c9b0264a2d8fdaa9821b45872..99a58ede387e05a909540ef9ccbaed92cc25c0b2 100644 (file)
@@ -225,22 +225,6 @@ noinline void btrfs_release_path(struct btrfs_path *p)
        }
 }
 
-/*
- * We want the transaction abort to print stack trace only for errors where the
- * cause could be a bug, eg. due to ENOSPC, and not for common errors that are
- * caused by external factors.
- */
-bool __cold abort_should_print_stack(int error)
-{
-       switch (error) {
-       case -EIO:
-       case -EROFS:
-       case -ENOMEM:
-               return false;
-       }
-       return true;
-}
-
 /*
  * safely gets a reference on the root node of a tree.  A lock
  * is not taken, so a concurrent writer may put a different node
index 184fa5c0062abf2ab802e0789ca75b098284ad18..9f7c777af6356c3cfaa6c706577ff436283b98eb 100644 (file)
@@ -227,7 +227,21 @@ static inline void btrfs_clear_skip_qgroup(struct btrfs_trans_handle *trans)
        delayed_refs->qgroup_to_skip = 0;
 }
 
-bool __cold abort_should_print_stack(int error);
+/*
+ * We want the transaction abort to print stack trace only for errors where the
+ * cause could be a bug, eg. due to ENOSPC, and not for common errors that are
+ * caused by external factors.
+ */
+static inline bool btrfs_abort_should_print_stack(int error)
+{
+       switch (error) {
+       case -EIO:
+       case -EROFS:
+       case -ENOMEM:
+               return false;
+       }
+       return true;
+}
 
 /*
  * Call btrfs_abort_transaction as early as possible when an error condition is
@@ -240,7 +254,7 @@ do {                                                                \
        if (!test_and_set_bit(BTRFS_FS_STATE_TRANS_ABORTED,     \
                        &((trans)->fs_info->fs_state))) {       \
                __first = true;                                 \
-               if (WARN(abort_should_print_stack(error),       \
+               if (WARN(btrfs_abort_should_print_stack(error), \
                        KERN_ERR                                \
                        "BTRFS: Transaction aborted (error %d)\n",      \
                        (error))) {                                     \