Commit b1818dab authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: backref: rename and move alloc_backref_node()

Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 584fb121
...@@ -2482,3 +2482,24 @@ void btrfs_backref_init_cache(struct btrfs_fs_info *fs_info, ...@@ -2482,3 +2482,24 @@ void btrfs_backref_init_cache(struct btrfs_fs_info *fs_info,
cache->fs_info = fs_info; cache->fs_info = fs_info;
cache->is_reloc = is_reloc; cache->is_reloc = is_reloc;
} }
struct btrfs_backref_node *btrfs_backref_alloc_node(
struct btrfs_backref_cache *cache, u64 bytenr, int level)
{
struct btrfs_backref_node *node;
ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL);
node = kzalloc(sizeof(*node), GFP_NOFS);
if (!node)
return 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;
}
...@@ -270,5 +270,7 @@ struct btrfs_backref_cache { ...@@ -270,5 +270,7 @@ struct btrfs_backref_cache {
void btrfs_backref_init_cache(struct btrfs_fs_info *fs_info, void btrfs_backref_init_cache(struct btrfs_fs_info *fs_info,
struct btrfs_backref_cache *cache, int is_reloc); struct btrfs_backref_cache *cache, int is_reloc);
struct btrfs_backref_node *btrfs_backref_alloc_node(
struct btrfs_backref_cache *cache, u64 bytenr, int level);
#endif #endif
...@@ -208,27 +208,6 @@ static void backref_cache_cleanup(struct btrfs_backref_cache *cache) ...@@ -208,27 +208,6 @@ static void backref_cache_cleanup(struct btrfs_backref_cache *cache)
ASSERT(!cache->nr_edges); ASSERT(!cache->nr_edges);
} }
static struct btrfs_backref_node *alloc_backref_node(
struct btrfs_backref_cache *cache, u64 bytenr, int level)
{
struct btrfs_backref_node *node;
ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL);
node = kzalloc(sizeof(*node), GFP_NOFS);
if (!node)
return 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 btrfs_backref_cache *cache, static void free_backref_node(struct btrfs_backref_cache *cache,
struct btrfs_backref_node *node) struct btrfs_backref_node *node)
{ {
...@@ -609,7 +588,7 @@ static int handle_direct_tree_backref(struct btrfs_backref_cache *cache, ...@@ -609,7 +588,7 @@ static int handle_direct_tree_backref(struct btrfs_backref_cache *cache,
rb_node = rb_simple_search(&cache->rb_root, ref_key->offset); rb_node = rb_simple_search(&cache->rb_root, ref_key->offset);
if (!rb_node) { if (!rb_node) {
/* Parent node not yet cached */ /* Parent node not yet cached */
upper = alloc_backref_node(cache, ref_key->offset, upper = btrfs_backref_alloc_node(cache, ref_key->offset,
cur->level + 1); cur->level + 1);
if (!upper) { if (!upper) {
free_backref_edge(cache, edge); free_backref_edge(cache, edge);
...@@ -729,8 +708,8 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache, ...@@ -729,8 +708,8 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,
eb = path->nodes[level]; eb = path->nodes[level];
rb_node = rb_simple_search(&cache->rb_root, eb->start); rb_node = rb_simple_search(&cache->rb_root, eb->start);
if (!rb_node) { if (!rb_node) {
upper = alloc_backref_node(cache, eb->start, upper = btrfs_backref_alloc_node(cache, eb->start,
lower->level + 1); lower->level + 1);
if (!upper) { if (!upper) {
btrfs_put_root(root); btrfs_put_root(root);
free_backref_edge(cache, edge); free_backref_edge(cache, edge);
...@@ -1135,7 +1114,7 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree( ...@@ -1135,7 +1114,7 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree(
goto out; goto out;
} }
node = alloc_backref_node(cache, bytenr, level); node = btrfs_backref_alloc_node(cache, bytenr, level);
if (!node) { if (!node) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
...@@ -1272,7 +1251,8 @@ static int clone_backref_node(struct btrfs_trans_handle *trans, ...@@ -1272,7 +1251,8 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
if (!node) if (!node)
return 0; return 0;
new_node = alloc_backref_node(cache, dest->node->start, node->level); new_node = btrfs_backref_alloc_node(cache, dest->node->start,
node->level);
if (!new_node) if (!new_node)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment