mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
btrfs: uninline some static inline helpers from backref.h
There are many helpers doing simple things but not simple enough to justify the static inline. None of them seems to be on a hot path so move them to .c. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
ef923440e2
commit
2aa756ec49
@ -2856,6 +2856,16 @@ struct btrfs_backref_iter *btrfs_backref_iter_alloc(struct btrfs_fs_info *fs_inf
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void btrfs_backref_iter_release(struct btrfs_backref_iter *iter)
|
||||||
|
{
|
||||||
|
iter->bytenr = 0;
|
||||||
|
iter->item_ptr = 0;
|
||||||
|
iter->cur_ptr = 0;
|
||||||
|
iter->end_ptr = 0;
|
||||||
|
btrfs_release_path(iter->path);
|
||||||
|
memset(&iter->cur_key, 0, sizeof(iter->cur_key));
|
||||||
|
}
|
||||||
|
|
||||||
int btrfs_backref_iter_start(struct btrfs_backref_iter *iter, u64 bytenr)
|
int btrfs_backref_iter_start(struct btrfs_backref_iter *iter, u64 bytenr)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = iter->fs_info;
|
struct btrfs_fs_info *fs_info = iter->fs_info;
|
||||||
@ -2948,6 +2958,14 @@ int btrfs_backref_iter_start(struct btrfs_backref_iter *iter, u64 bytenr)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool btrfs_backref_iter_is_inline_ref(struct btrfs_backref_iter *iter)
|
||||||
|
{
|
||||||
|
if (iter->cur_key.type == BTRFS_EXTENT_ITEM_KEY ||
|
||||||
|
iter->cur_key.type == BTRFS_METADATA_ITEM_KEY)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Go to the next backref item of current bytenr, can be either inlined or
|
* Go to the next backref item of current bytenr, can be either inlined or
|
||||||
* keyed.
|
* keyed.
|
||||||
@ -3048,6 +3066,19 @@ struct btrfs_backref_node *btrfs_backref_alloc_node(
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void btrfs_backref_free_node(struct btrfs_backref_cache *cache,
|
||||||
|
struct btrfs_backref_node *node)
|
||||||
|
{
|
||||||
|
if (node) {
|
||||||
|
ASSERT(list_empty(&node->list));
|
||||||
|
ASSERT(list_empty(&node->lower));
|
||||||
|
ASSERT(node->eb == NULL);
|
||||||
|
cache->nr_nodes--;
|
||||||
|
btrfs_put_root(node->root);
|
||||||
|
kfree(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct btrfs_backref_edge *btrfs_backref_alloc_edge(
|
struct btrfs_backref_edge *btrfs_backref_alloc_edge(
|
||||||
struct btrfs_backref_cache *cache)
|
struct btrfs_backref_cache *cache)
|
||||||
{
|
{
|
||||||
@ -3059,6 +3090,52 @@ struct btrfs_backref_edge *btrfs_backref_alloc_edge(
|
|||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void btrfs_backref_free_edge(struct btrfs_backref_cache *cache,
|
||||||
|
struct btrfs_backref_edge *edge)
|
||||||
|
{
|
||||||
|
if (edge) {
|
||||||
|
cache->nr_edges--;
|
||||||
|
kfree(edge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void btrfs_backref_unlock_node_buffer(struct btrfs_backref_node *node)
|
||||||
|
{
|
||||||
|
if (node->locked) {
|
||||||
|
btrfs_tree_unlock(node->eb);
|
||||||
|
node->locked = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void btrfs_backref_drop_node_buffer(struct btrfs_backref_node *node)
|
||||||
|
{
|
||||||
|
if (node->eb) {
|
||||||
|
btrfs_backref_unlock_node_buffer(node);
|
||||||
|
free_extent_buffer(node->eb);
|
||||||
|
node->eb = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Drop the backref node from cache without cleaning up its children
|
||||||
|
* edges.
|
||||||
|
*
|
||||||
|
* This can only be called on node without parent edges.
|
||||||
|
* The children edges are still kept as is.
|
||||||
|
*/
|
||||||
|
void btrfs_backref_drop_node(struct btrfs_backref_cache *tree,
|
||||||
|
struct btrfs_backref_node *node)
|
||||||
|
{
|
||||||
|
ASSERT(list_empty(&node->upper));
|
||||||
|
|
||||||
|
btrfs_backref_drop_node_buffer(node);
|
||||||
|
list_del_init(&node->list);
|
||||||
|
list_del_init(&node->lower);
|
||||||
|
if (!RB_EMPTY_NODE(&node->rb_node))
|
||||||
|
rb_erase(&node->rb_node, &tree->rb_root);
|
||||||
|
btrfs_backref_free_node(tree, node);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drop the backref node from cache, also cleaning up all its
|
* Drop the backref node from cache, also cleaning up all its
|
||||||
* upper edges and any uncached nodes in the path.
|
* upper edges and any uncached nodes in the path.
|
||||||
@ -3130,6 +3207,19 @@ void btrfs_backref_release_cache(struct btrfs_backref_cache *cache)
|
|||||||
ASSERT(!cache->nr_edges);
|
ASSERT(!cache->nr_edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void btrfs_backref_link_edge(struct btrfs_backref_edge *edge,
|
||||||
|
struct btrfs_backref_node *lower,
|
||||||
|
struct btrfs_backref_node *upper,
|
||||||
|
int link_which)
|
||||||
|
{
|
||||||
|
ASSERT(upper && lower && upper->level == lower->level + 1);
|
||||||
|
edge->node[LOWER] = lower;
|
||||||
|
edge->node[UPPER] = upper;
|
||||||
|
if (link_which & LINK_LOWER)
|
||||||
|
list_add_tail(&edge->list[LOWER], &lower->upper);
|
||||||
|
if (link_which & LINK_UPPER)
|
||||||
|
list_add_tail(&edge->list[UPPER], &upper->lower);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Handle direct tree backref
|
* Handle direct tree backref
|
||||||
*
|
*
|
||||||
|
@ -302,25 +302,6 @@ int btrfs_backref_iter_start(struct btrfs_backref_iter *iter, u64 bytenr);
|
|||||||
|
|
||||||
int btrfs_backref_iter_next(struct btrfs_backref_iter *iter);
|
int btrfs_backref_iter_next(struct btrfs_backref_iter *iter);
|
||||||
|
|
||||||
static inline bool btrfs_backref_iter_is_inline_ref(
|
|
||||||
struct btrfs_backref_iter *iter)
|
|
||||||
{
|
|
||||||
if (iter->cur_key.type == BTRFS_EXTENT_ITEM_KEY ||
|
|
||||||
iter->cur_key.type == BTRFS_METADATA_ITEM_KEY)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void btrfs_backref_iter_release(struct btrfs_backref_iter *iter)
|
|
||||||
{
|
|
||||||
iter->bytenr = 0;
|
|
||||||
iter->item_ptr = 0;
|
|
||||||
iter->cur_ptr = 0;
|
|
||||||
iter->end_ptr = 0;
|
|
||||||
btrfs_release_path(iter->path);
|
|
||||||
memset(&iter->cur_key, 0, sizeof(iter->cur_key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Backref cache related structures
|
* Backref cache related structures
|
||||||
*
|
*
|
||||||
@ -448,83 +429,22 @@ struct btrfs_backref_edge *btrfs_backref_alloc_edge(
|
|||||||
|
|
||||||
#define LINK_LOWER (1 << 0)
|
#define LINK_LOWER (1 << 0)
|
||||||
#define LINK_UPPER (1 << 1)
|
#define LINK_UPPER (1 << 1)
|
||||||
static inline void btrfs_backref_link_edge(struct btrfs_backref_edge *edge,
|
|
||||||
struct btrfs_backref_node *lower,
|
|
||||||
struct btrfs_backref_node *upper,
|
|
||||||
int link_which)
|
|
||||||
{
|
|
||||||
ASSERT(upper && lower && upper->level == lower->level + 1);
|
|
||||||
edge->node[LOWER] = lower;
|
|
||||||
edge->node[UPPER] = upper;
|
|
||||||
if (link_which & LINK_LOWER)
|
|
||||||
list_add_tail(&edge->list[LOWER], &lower->upper);
|
|
||||||
if (link_which & LINK_UPPER)
|
|
||||||
list_add_tail(&edge->list[UPPER], &upper->lower);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void btrfs_backref_free_node(struct btrfs_backref_cache *cache,
|
void btrfs_backref_link_edge(struct btrfs_backref_edge *edge,
|
||||||
struct btrfs_backref_node *node)
|
struct btrfs_backref_node *lower,
|
||||||
{
|
struct btrfs_backref_node *upper,
|
||||||
if (node) {
|
int link_which);
|
||||||
ASSERT(list_empty(&node->list));
|
void btrfs_backref_free_node(struct btrfs_backref_cache *cache,
|
||||||
ASSERT(list_empty(&node->lower));
|
struct btrfs_backref_node *node);
|
||||||
ASSERT(node->eb == NULL);
|
void btrfs_backref_free_edge(struct btrfs_backref_cache *cache,
|
||||||
cache->nr_nodes--;
|
struct btrfs_backref_edge *edge);
|
||||||
btrfs_put_root(node->root);
|
void btrfs_backref_unlock_node_buffer(struct btrfs_backref_node *node);
|
||||||
kfree(node);
|
void btrfs_backref_drop_node_buffer(struct btrfs_backref_node *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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void btrfs_backref_unlock_node_buffer(
|
|
||||||
struct btrfs_backref_node *node)
|
|
||||||
{
|
|
||||||
if (node->locked) {
|
|
||||||
btrfs_tree_unlock(node->eb);
|
|
||||||
node->locked = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void btrfs_backref_drop_node_buffer(
|
|
||||||
struct btrfs_backref_node *node)
|
|
||||||
{
|
|
||||||
if (node->eb) {
|
|
||||||
btrfs_backref_unlock_node_buffer(node);
|
|
||||||
free_extent_buffer(node->eb);
|
|
||||||
node->eb = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Drop the backref node from cache without cleaning up its children
|
|
||||||
* edges.
|
|
||||||
*
|
|
||||||
* This can only be called on node without parent edges.
|
|
||||||
* The children edges are still kept as is.
|
|
||||||
*/
|
|
||||||
static inline void btrfs_backref_drop_node(struct btrfs_backref_cache *tree,
|
|
||||||
struct btrfs_backref_node *node)
|
|
||||||
{
|
|
||||||
ASSERT(list_empty(&node->upper));
|
|
||||||
|
|
||||||
btrfs_backref_drop_node_buffer(node);
|
|
||||||
list_del_init(&node->list);
|
|
||||||
list_del_init(&node->lower);
|
|
||||||
if (!RB_EMPTY_NODE(&node->rb_node))
|
|
||||||
rb_erase(&node->rb_node, &tree->rb_root);
|
|
||||||
btrfs_backref_free_node(tree, node);
|
|
||||||
}
|
|
||||||
|
|
||||||
void btrfs_backref_cleanup_node(struct btrfs_backref_cache *cache,
|
void btrfs_backref_cleanup_node(struct btrfs_backref_cache *cache,
|
||||||
struct btrfs_backref_node *node);
|
struct btrfs_backref_node *node);
|
||||||
|
void btrfs_backref_drop_node(struct btrfs_backref_cache *tree,
|
||||||
|
struct btrfs_backref_node *node);
|
||||||
|
|
||||||
void btrfs_backref_release_cache(struct btrfs_backref_cache *cache);
|
void btrfs_backref_release_cache(struct btrfs_backref_cache *cache);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user