Commit 741188d3 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: backref: rename and move free_backref_(node|edge)

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 f39911e5
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/btrfs.h> #include <linux/btrfs.h>
#include "ulist.h" #include "ulist.h"
#include "disk-io.h"
#include "extent_io.h" #include "extent_io.h"
struct inode_fs_paths { struct inode_fs_paths {
...@@ -291,4 +292,23 @@ static inline void btrfs_backref_link_edge(struct btrfs_backref_edge *edge, ...@@ -291,4 +292,23 @@ static inline void btrfs_backref_link_edge(struct btrfs_backref_edge *edge,
list_add_tail(&edge->list[UPPER], &upper->lower); list_add_tail(&edge->list[UPPER], &upper->lower);
} }
static inline void btrfs_backref_free_node(struct btrfs_backref_cache *cache,
struct btrfs_backref_node *node)
{
if (node) {
cache->nr_nodes--;
btrfs_put_root(node->root);
kfree(node);
}
}
static inline void btrfs_backref_free_edge(struct btrfs_backref_cache *cache,
struct btrfs_backref_edge *edge)
{
if (edge) {
cache->nr_edges--;
kfree(edge);
}
}
#endif #endif
...@@ -208,26 +208,6 @@ static void backref_cache_cleanup(struct btrfs_backref_cache *cache) ...@@ -208,26 +208,6 @@ static void backref_cache_cleanup(struct btrfs_backref_cache *cache)
ASSERT(!cache->nr_edges); ASSERT(!cache->nr_edges);
} }
static void free_backref_node(struct btrfs_backref_cache *cache,
struct btrfs_backref_node *node)
{
if (node) {
cache->nr_nodes--;
btrfs_put_root(node->root);
kfree(node);
}
}
static void free_backref_edge(struct btrfs_backref_cache *cache,
struct btrfs_backref_edge *edge)
{
if (edge) {
cache->nr_edges--;
kfree(edge);
}
}
static void backref_tree_panic(struct rb_node *rb_node, int errno, u64 bytenr) static void backref_tree_panic(struct rb_node *rb_node, int errno, u64 bytenr)
{ {
...@@ -316,7 +296,7 @@ static void drop_backref_node(struct btrfs_backref_cache *tree, ...@@ -316,7 +296,7 @@ static void drop_backref_node(struct btrfs_backref_cache *tree,
list_del(&node->lower); list_del(&node->lower);
if (!RB_EMPTY_NODE(&node->rb_node)) if (!RB_EMPTY_NODE(&node->rb_node))
rb_erase(&node->rb_node, &tree->rb_root); rb_erase(&node->rb_node, &tree->rb_root);
free_backref_node(tree, node); btrfs_backref_free_node(tree, node);
} }
/* /*
...@@ -338,7 +318,7 @@ static void remove_backref_node(struct btrfs_backref_cache *cache, ...@@ -338,7 +318,7 @@ static void remove_backref_node(struct btrfs_backref_cache *cache,
upper = edge->node[UPPER]; upper = edge->node[UPPER];
list_del(&edge->list[LOWER]); list_del(&edge->list[LOWER]);
list_del(&edge->list[UPPER]); list_del(&edge->list[UPPER]);
free_backref_edge(cache, edge); btrfs_backref_free_edge(cache, edge);
if (RB_EMPTY_NODE(&upper->rb_node)) { if (RB_EMPTY_NODE(&upper->rb_node)) {
BUG_ON(!list_empty(&node->upper)); BUG_ON(!list_empty(&node->upper));
...@@ -565,7 +545,7 @@ static int handle_direct_tree_backref(struct btrfs_backref_cache *cache, ...@@ -565,7 +545,7 @@ static int handle_direct_tree_backref(struct btrfs_backref_cache *cache,
upper = btrfs_backref_alloc_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); btrfs_backref_free_edge(cache, edge);
return -ENOMEM; return -ENOMEM;
} }
...@@ -686,7 +666,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache, ...@@ -686,7 +666,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,
lower->level + 1); lower->level + 1);
if (!upper) { if (!upper) {
btrfs_put_root(root); btrfs_put_root(root);
free_backref_edge(cache, edge); btrfs_backref_free_edge(cache, edge);
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
...@@ -915,7 +895,7 @@ static int finish_upper_links(struct btrfs_backref_cache *cache, ...@@ -915,7 +895,7 @@ static int finish_upper_links(struct btrfs_backref_cache *cache,
/* Parent is detached, no need to keep any edges */ /* Parent is detached, no need to keep any edges */
if (upper->detached) { if (upper->detached) {
list_del(&edge->list[LOWER]); list_del(&edge->list[LOWER]);
free_backref_edge(cache, edge); btrfs_backref_free_edge(cache, edge);
/* Lower node is orphan, queue for cleanup */ /* Lower node is orphan, queue for cleanup */
if (list_empty(&lower->upper)) if (list_empty(&lower->upper))
...@@ -1024,7 +1004,7 @@ static bool handle_useless_nodes(struct reloc_control *rc, ...@@ -1024,7 +1004,7 @@ static bool handle_useless_nodes(struct reloc_control *rc,
list_del(&edge->list[UPPER]); list_del(&edge->list[UPPER]);
list_del(&edge->list[LOWER]); list_del(&edge->list[LOWER]);
lower = edge->node[LOWER]; lower = edge->node[LOWER];
free_backref_edge(cache, edge); btrfs_backref_free_edge(cache, edge);
/* Child node is also orphan, queue for cleanup */ /* Child node is also orphan, queue for cleanup */
if (list_empty(&lower->upper)) if (list_empty(&lower->upper))
...@@ -1043,7 +1023,7 @@ static bool handle_useless_nodes(struct reloc_control *rc, ...@@ -1043,7 +1023,7 @@ static bool handle_useless_nodes(struct reloc_control *rc,
cur->detached = 1; cur->detached = 1;
} else { } else {
rb_erase(&cur->rb_node, &cache->rb_root); rb_erase(&cur->rb_node, &cache->rb_root);
free_backref_node(cache, cur); btrfs_backref_free_node(cache, cur);
} }
} }
return ret; return ret;
...@@ -1141,7 +1121,7 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree( ...@@ -1141,7 +1121,7 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree(
list_del(&edge->list[LOWER]); list_del(&edge->list[LOWER]);
lower = edge->node[LOWER]; lower = edge->node[LOWER];
upper = edge->node[UPPER]; upper = edge->node[UPPER];
free_backref_edge(cache, edge); btrfs_backref_free_edge(cache, edge);
/* /*
* Lower is no longer linked to any upper backref nodes * Lower is no longer linked to any upper backref nodes
...@@ -1168,7 +1148,7 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree( ...@@ -1168,7 +1148,7 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree(
list_del_init(&lower->list); list_del_init(&lower->list);
if (lower == node) if (lower == node)
node = NULL; node = NULL;
free_backref_node(cache, lower); btrfs_backref_free_node(cache, lower);
} }
remove_backref_node(cache, node); remove_backref_node(cache, node);
...@@ -1265,9 +1245,9 @@ static int clone_backref_node(struct btrfs_trans_handle *trans, ...@@ -1265,9 +1245,9 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
new_edge = list_entry(new_node->lower.next, new_edge = list_entry(new_node->lower.next,
struct btrfs_backref_edge, list[UPPER]); struct btrfs_backref_edge, list[UPPER]);
list_del(&new_edge->list[UPPER]); list_del(&new_edge->list[UPPER]);
free_backref_edge(cache, new_edge); btrfs_backref_free_edge(cache, new_edge);
} }
free_backref_node(cache, new_node); btrfs_backref_free_node(cache, 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