btrfs: move btrfs_map_token to accessors
authorJosef Bacik <josef@toxicpanda.com>
Wed, 19 Oct 2022 14:50:59 +0000 (10:50 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 5 Dec 2022 17:00:42 +0000 (18:00 +0100)
This is specific to the item-accessor code, move it out of ctree.h into
accessor.h/.c and then update the users to include the new header file.
This un-inlines btrfs_init_map_token, however this is only called once
per function so it's not critical to be inlined.  This also saves 904
bytes of code on a release build.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/accessors.c
fs/btrfs/accessors.h [new file with mode: 0644]
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/inode.c
fs/btrfs/tree-log.c

index 118bfd1c0e3e2cc1db0b2e01424f8e12d83ecbe4..7a7b7d263102faa7e87ec26a6dd45ac8bf3bf9d3 100644 (file)
@@ -6,6 +6,7 @@
 #include <asm/unaligned.h>
 #include "messages.h"
 #include "ctree.h"
+#include "accessors.h"
 
 static bool check_setget_bounds(const struct extent_buffer *eb,
                                const void *ptr, unsigned off, int size)
@@ -23,6 +24,13 @@ static bool check_setget_bounds(const struct extent_buffer *eb,
        return true;
 }
 
+void btrfs_init_map_token(struct btrfs_map_token *token, struct extent_buffer *eb)
+{
+       token->eb = eb;
+       token->kaddr = page_address(eb->pages[0]);
+       token->offset = 0;
+}
+
 /*
  * Macro templates that define helpers to read/write extent buffer data of a
  * given size, that are also used via ctree.h for access to item members by
diff --git a/fs/btrfs/accessors.h b/fs/btrfs/accessors.h
new file mode 100644 (file)
index 0000000..a47b0f9
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef BTRFS_ACCESSORS_H
+#define BTRFS_ACCESSORS_H
+
+struct btrfs_map_token {
+       struct extent_buffer *eb;
+       char *kaddr;
+       unsigned long offset;
+};
+
+void btrfs_init_map_token(struct btrfs_map_token *token, struct extent_buffer *eb);
+
+#endif
index 7ecb658500cea5024aaaff9b6ccda3815ba8c6a7..1283ca46c5bc9aa13c279e8cc967a83aa8817fd5 100644 (file)
@@ -19,6 +19,7 @@
 #include "tree-mod-log.h"
 #include "tree-checker.h"
 #include "fs.h"
+#include "accessors.h"
 
 static struct kmem_cache *btrfs_path_cachep;
 
index af6b72c7e33f60038b0b0b4b15b4e0e5ac5f87b1..296ca4de8d5241400f5b5d6ceb548e6eb70c4290 100644 (file)
@@ -52,6 +52,8 @@ struct btrfs_balance_control;
 struct btrfs_delayed_root;
 struct reloc_control;
 
+struct btrfs_map_token;
+
 #define BTRFS_OLDEST_GENERATION        0ULL
 
 #define BTRFS_EMPTY_DIR_SIZE 0
@@ -1199,23 +1201,9 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
        return BTRFS_MAX_ITEM_SIZE(info) - sizeof(struct btrfs_dir_item);
 }
 
-struct btrfs_map_token {
-       struct extent_buffer *eb;
-       char *kaddr;
-       unsigned long offset;
-};
-
 #define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \
                                ((bytes) >> (fs_info)->sectorsize_bits)
 
-static inline void btrfs_init_map_token(struct btrfs_map_token *token,
-                                       struct extent_buffer *eb)
-{
-       token->eb = eb;
-       token->kaddr = page_address(eb->pages[0]);
-       token->offset = 0;
-}
-
 /* some macros to generate set/get functions for the struct fields.  This
  * assumes there is a lefoo_to_cpu for every type, so lets make a simple
  * one for u8:
index 60b3162c035d0e3b3cc6b1f9b04456067b0fad1b..cb2a6d7f62528e1b7984f95a23e5cbdd3f4cee40 100644 (file)
@@ -56,6 +56,7 @@
 #include "subpage.h"
 #include "inode-item.h"
 #include "fs.h"
+#include "accessors.h"
 
 struct btrfs_iget_args {
        u64 ino;
index e294c38f9b1995a2c6210864a4a8f41fb4b934b3..dc49f0aae1fb24c996bf52463f8200e557e444bb 100644 (file)
@@ -22,6 +22,7 @@
 #include "zoned.h"
 #include "inode-item.h"
 #include "fs.h"
+#include "accessors.h"
 
 #define MAX_CONFLICT_INODES 10