[PATCH 07/19] btrfs: Move alloc_backref_node() to backref.c

Qu Wenruo
2020-03-03T07:15:20Z

fs/btrfs/backref.c | 20 ++++++++++++++++++++
fs/btrfs/backref.h | 2 ++
fs/btrfs/relocation.c | 20 --------------------
3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 8fc1d520695e..b6183cb7c60b 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -2460,3 +2460,23 @@ void backref_cache_init(struct btrfs_fs_info *fs_info,
INIT_LIST_HEAD(&cache->pending_edge);
INIT_LIST_HEAD(&cache->useless_node);
}
+
+struct backref_node *alloc_backref_node(struct backref_cache *cache,
+ u64 bytenr, int level)
+{
+ struct backref_node *node;
+
+ ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL);
+ node = kzalloc(sizeof(*node), GFP_NOFS);
+ if (node) {
+ INIT_LIST_HEAD(&node->list);
+ INIT_LIST_HEAD(&node->upper);
+ INIT_LIST_HEAD(&node->lower);
+ RB_CLEAR_NODE(&node->rb_node);
+ cache->nr_nodes++;
+
+ node->level = level;
+ node->bytenr = bytenr;
+ }
+ return node;
+}
diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h
index 65e886fb2008..b7aad5f116ae 100644
--- a/fs/btrfs/backref.h
+++ b/fs/btrfs/backref.h
@@ -292,4 +292,6 @@ struct backref_cache {

void backref_cache_init(struct btrfs_fs_info *fs_info,
struct backref_cache *cache, int is_reloc);
+struct backref_node *alloc_backref_node(struct backref_cache *cache,
+ u64 bytenr, int level);
#endif
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 4ec2946f95ae..f97ff88dba21 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -215,26 +215,6 @@ static void backref_cache_cleanup(struct backref_cache *cache)
ASSERT(!cache->nr_edges);
}

-static struct backref_node *alloc_backref_node(struct backref_cache *cache,
- u64 bytenr, int level)
-{
- struct backref_node *node;
-
- ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL);
- node = kzalloc(sizeof(*node), GFP_NOFS);
- if (node) {
- INIT_LIST_HEAD(&node->list);
- INIT_LIST_HEAD(&node->upper);
- INIT_LIST_HEAD(&node->lower);
- RB_CLEAR_NODE(&node->rb_node);
- cache->nr_nodes++;
-
- node->level = level;
- node->bytenr = bytenr;
- }
- return node;
-}
-
static void free_backref_node(struct backref_cache *cache,
struct backref_node *node)
{
--
2.25.1