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

btrfs: reloc: add btrfs_ prefix for backref_node/edge/cache

Those three structures are the main elements of backref cache. Add the
"btrfs_" prefix for later export.
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 29db137b
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
*/ */
/* /*
* backref_node, mapping_node and tree_block start with this * btrfs_backref_node, mapping_node and tree_block start with this
*/ */
struct tree_entry { struct tree_entry {
struct rb_node rb_node; struct rb_node rb_node;
...@@ -83,7 +83,7 @@ struct tree_entry { ...@@ -83,7 +83,7 @@ struct tree_entry {
/* /*
* present a tree block in the backref cache * present a tree block in the backref cache
*/ */
struct backref_node { struct btrfs_backref_node {
struct rb_node rb_node; struct rb_node rb_node;
u64 bytenr; u64 bytenr;
...@@ -138,10 +138,11 @@ struct backref_node { ...@@ -138,10 +138,11 @@ struct backref_node {
/* /*
* present an edge connecting upper and lower backref nodes. * present an edge connecting upper and lower backref nodes.
*/ */
struct backref_edge { struct btrfs_backref_edge {
/* /*
* list[LOWER] is linked to backref_node::upper of lower level node, * list[LOWER] is linked to btrfs_backref_node::upper of lower level
* and list[UPPER] is linked to backref_node::lower of upper level node. * node, and list[UPPER] is linked to btrfs_backref_node::lower of
* upper level node.
* *
* Also, build_backref_tree() uses list[UPPER] for pending edges, before * Also, build_backref_tree() uses list[UPPER] for pending edges, before
* linking list[UPPER] to its upper level nodes. * linking list[UPPER] to its upper level nodes.
...@@ -149,15 +150,15 @@ struct backref_edge { ...@@ -149,15 +150,15 @@ struct backref_edge {
struct list_head list[2]; struct list_head list[2];
/* Two related nodes */ /* Two related nodes */
struct backref_node *node[2]; struct btrfs_backref_node *node[2];
}; };
struct backref_cache { struct btrfs_backref_cache {
/* red black tree of all backref nodes in the cache */ /* red black tree of all backref nodes in the cache */
struct rb_root rb_root; struct rb_root rb_root;
/* for passing backref nodes to btrfs_reloc_cow_block */ /* for passing backref nodes to btrfs_reloc_cow_block */
struct backref_node *path[BTRFS_MAX_LEVEL]; struct btrfs_backref_node *path[BTRFS_MAX_LEVEL];
/* /*
* list of blocks that have been cowed but some block * list of blocks that have been cowed but some block
* pointers in upper level blocks may not reflect the * pointers in upper level blocks may not reflect the
...@@ -237,7 +238,7 @@ struct reloc_control { ...@@ -237,7 +238,7 @@ struct reloc_control {
struct btrfs_block_rsv *block_rsv; struct btrfs_block_rsv *block_rsv;
struct backref_cache backref_cache; struct btrfs_backref_cache backref_cache;
struct file_extent_cluster cluster; struct file_extent_cluster cluster;
/* tree blocks have been processed */ /* tree blocks have been processed */
...@@ -268,11 +269,11 @@ struct reloc_control { ...@@ -268,11 +269,11 @@ struct reloc_control {
#define MOVE_DATA_EXTENTS 0 #define MOVE_DATA_EXTENTS 0
#define UPDATE_DATA_PTRS 1 #define UPDATE_DATA_PTRS 1
static void remove_backref_node(struct backref_cache *cache, static void remove_backref_node(struct btrfs_backref_cache *cache,
struct backref_node *node); struct btrfs_backref_node *node);
static void mark_block_processed(struct reloc_control *rc, static void mark_block_processed(struct reloc_control *rc,
struct backref_node *node) struct btrfs_backref_node *node)
{ {
u32 blocksize; u32 blocksize;
...@@ -294,7 +295,7 @@ static void mapping_tree_init(struct mapping_tree *tree) ...@@ -294,7 +295,7 @@ static void mapping_tree_init(struct mapping_tree *tree)
} }
static void backref_cache_init(struct btrfs_fs_info *fs_info, static void backref_cache_init(struct btrfs_fs_info *fs_info,
struct backref_cache *cache, int is_reloc) struct btrfs_backref_cache *cache, int is_reloc)
{ {
int i; int i;
cache->rb_root = RB_ROOT; cache->rb_root = RB_ROOT;
...@@ -309,20 +310,20 @@ static void backref_cache_init(struct btrfs_fs_info *fs_info, ...@@ -309,20 +310,20 @@ static void backref_cache_init(struct btrfs_fs_info *fs_info,
cache->is_reloc = is_reloc; cache->is_reloc = is_reloc;
} }
static void backref_cache_cleanup(struct backref_cache *cache) static void backref_cache_cleanup(struct btrfs_backref_cache *cache)
{ {
struct backref_node *node; struct btrfs_backref_node *node;
int i; int i;
while (!list_empty(&cache->detached)) { while (!list_empty(&cache->detached)) {
node = list_entry(cache->detached.next, node = list_entry(cache->detached.next,
struct backref_node, list); struct btrfs_backref_node, list);
remove_backref_node(cache, node); remove_backref_node(cache, node);
} }
while (!list_empty(&cache->leaves)) { while (!list_empty(&cache->leaves)) {
node = list_entry(cache->leaves.next, node = list_entry(cache->leaves.next,
struct backref_node, lower); struct btrfs_backref_node, lower);
remove_backref_node(cache, node); remove_backref_node(cache, node);
} }
...@@ -339,10 +340,10 @@ static void backref_cache_cleanup(struct backref_cache *cache) ...@@ -339,10 +340,10 @@ static void backref_cache_cleanup(struct backref_cache *cache)
ASSERT(!cache->nr_edges); ASSERT(!cache->nr_edges);
} }
static struct backref_node *alloc_backref_node(struct backref_cache *cache, static struct btrfs_backref_node *alloc_backref_node(
u64 bytenr, int level) struct btrfs_backref_cache *cache, u64 bytenr, int level)
{ {
struct backref_node *node; struct btrfs_backref_node *node;
ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL); ASSERT(level >= 0 && level < BTRFS_MAX_LEVEL);
node = kzalloc(sizeof(*node), GFP_NOFS); node = kzalloc(sizeof(*node), GFP_NOFS);
...@@ -360,8 +361,8 @@ static struct backref_node *alloc_backref_node(struct backref_cache *cache, ...@@ -360,8 +361,8 @@ static struct backref_node *alloc_backref_node(struct backref_cache *cache,
return node; return node;
} }
static void free_backref_node(struct backref_cache *cache, static void free_backref_node(struct btrfs_backref_cache *cache,
struct backref_node *node) struct btrfs_backref_node *node)
{ {
if (node) { if (node) {
cache->nr_nodes--; cache->nr_nodes--;
...@@ -370,9 +371,10 @@ static void free_backref_node(struct backref_cache *cache, ...@@ -370,9 +371,10 @@ static void free_backref_node(struct backref_cache *cache,
} }
} }
static struct backref_edge *alloc_backref_edge(struct backref_cache *cache) static struct btrfs_backref_edge *alloc_backref_edge(
struct btrfs_backref_cache *cache)
{ {
struct backref_edge *edge; struct btrfs_backref_edge *edge;
edge = kzalloc(sizeof(*edge), GFP_NOFS); edge = kzalloc(sizeof(*edge), GFP_NOFS);
if (edge) if (edge)
...@@ -382,9 +384,9 @@ static struct backref_edge *alloc_backref_edge(struct backref_cache *cache) ...@@ -382,9 +384,9 @@ static struct backref_edge *alloc_backref_edge(struct backref_cache *cache)
#define LINK_LOWER (1 << 0) #define LINK_LOWER (1 << 0)
#define LINK_UPPER (1 << 1) #define LINK_UPPER (1 << 1)
static void link_backref_edge(struct backref_edge *edge, static void link_backref_edge(struct btrfs_backref_edge *edge,
struct backref_node *lower, struct btrfs_backref_node *lower,
struct backref_node *upper, struct btrfs_backref_node *upper,
int link_which) int link_which)
{ {
ASSERT(upper && lower && upper->level == lower->level + 1); ASSERT(upper && lower && upper->level == lower->level + 1);
...@@ -396,8 +398,8 @@ static void link_backref_edge(struct backref_edge *edge, ...@@ -396,8 +398,8 @@ static void link_backref_edge(struct backref_edge *edge,
list_add_tail(&edge->list[UPPER], &upper->lower); list_add_tail(&edge->list[UPPER], &upper->lower);
} }
static void free_backref_edge(struct backref_cache *cache, static void free_backref_edge(struct btrfs_backref_cache *cache,
struct backref_edge *edge) struct btrfs_backref_edge *edge)
{ {
if (edge) { if (edge) {
cache->nr_edges--; cache->nr_edges--;
...@@ -451,8 +453,8 @@ static void backref_tree_panic(struct rb_node *rb_node, int errno, u64 bytenr) ...@@ -451,8 +453,8 @@ static void backref_tree_panic(struct rb_node *rb_node, int errno, u64 bytenr)
{ {
struct btrfs_fs_info *fs_info = NULL; struct btrfs_fs_info *fs_info = NULL;
struct backref_node *bnode = rb_entry(rb_node, struct backref_node, struct btrfs_backref_node *bnode = rb_entry(rb_node,
rb_node); struct btrfs_backref_node, rb_node);
if (bnode->root) if (bnode->root)
fs_info = bnode->root->fs_info; fs_info = bnode->root->fs_info;
btrfs_panic(fs_info, errno, btrfs_panic(fs_info, errno,
...@@ -463,16 +465,16 @@ static void backref_tree_panic(struct rb_node *rb_node, int errno, u64 bytenr) ...@@ -463,16 +465,16 @@ static void backref_tree_panic(struct rb_node *rb_node, int errno, u64 bytenr)
/* /*
* walk up backref nodes until reach node presents tree root * walk up backref nodes until reach node presents tree root
*/ */
static struct backref_node *walk_up_backref(struct backref_node *node, static struct btrfs_backref_node *walk_up_backref(
struct backref_edge *edges[], struct btrfs_backref_node *node,
int *index) struct btrfs_backref_edge *edges[], int *index)
{ {
struct backref_edge *edge; struct btrfs_backref_edge *edge;
int idx = *index; int idx = *index;
while (!list_empty(&node->upper)) { while (!list_empty(&node->upper)) {
edge = list_entry(node->upper.next, edge = list_entry(node->upper.next,
struct backref_edge, list[LOWER]); struct btrfs_backref_edge, list[LOWER]);
edges[idx++] = edge; edges[idx++] = edge;
node = edge->node[UPPER]; node = edge->node[UPPER];
} }
...@@ -484,11 +486,11 @@ static struct backref_node *walk_up_backref(struct backref_node *node, ...@@ -484,11 +486,11 @@ static struct backref_node *walk_up_backref(struct backref_node *node,
/* /*
* walk down backref nodes to find start of next reference path * walk down backref nodes to find start of next reference path
*/ */
static struct backref_node *walk_down_backref(struct backref_edge *edges[], static struct btrfs_backref_node *walk_down_backref(
int *index) struct btrfs_backref_edge *edges[], int *index)
{ {
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_node *lower; struct btrfs_backref_node *lower;
int idx = *index; int idx = *index;
while (idx > 0) { while (idx > 0) {
...@@ -499,7 +501,7 @@ static struct backref_node *walk_down_backref(struct backref_edge *edges[], ...@@ -499,7 +501,7 @@ static struct backref_node *walk_down_backref(struct backref_edge *edges[],
continue; continue;
} }
edge = list_entry(edge->list[LOWER].next, edge = list_entry(edge->list[LOWER].next,
struct backref_edge, list[LOWER]); struct btrfs_backref_edge, list[LOWER]);
edges[idx - 1] = edge; edges[idx - 1] = edge;
*index = idx; *index = idx;
return edge->node[UPPER]; return edge->node[UPPER];
...@@ -508,7 +510,7 @@ static struct backref_node *walk_down_backref(struct backref_edge *edges[], ...@@ -508,7 +510,7 @@ static struct backref_node *walk_down_backref(struct backref_edge *edges[],
return NULL; return NULL;
} }
static void unlock_node_buffer(struct backref_node *node) static void unlock_node_buffer(struct btrfs_backref_node *node)
{ {
if (node->locked) { if (node->locked) {
btrfs_tree_unlock(node->eb); btrfs_tree_unlock(node->eb);
...@@ -516,7 +518,7 @@ static void unlock_node_buffer(struct backref_node *node) ...@@ -516,7 +518,7 @@ static void unlock_node_buffer(struct backref_node *node)
} }
} }
static void drop_node_buffer(struct backref_node *node) static void drop_node_buffer(struct btrfs_backref_node *node)
{ {
if (node->eb) { if (node->eb) {
unlock_node_buffer(node); unlock_node_buffer(node);
...@@ -525,8 +527,8 @@ static void drop_node_buffer(struct backref_node *node) ...@@ -525,8 +527,8 @@ static void drop_node_buffer(struct backref_node *node)
} }
} }
static void drop_backref_node(struct backref_cache *tree, static void drop_backref_node(struct btrfs_backref_cache *tree,
struct backref_node *node) struct btrfs_backref_node *node)
{ {
BUG_ON(!list_empty(&node->upper)); BUG_ON(!list_empty(&node->upper));
...@@ -541,18 +543,18 @@ static void drop_backref_node(struct backref_cache *tree, ...@@ -541,18 +543,18 @@ static void drop_backref_node(struct backref_cache *tree,
/* /*
* remove a backref node from the backref cache * remove a backref node from the backref cache
*/ */
static void remove_backref_node(struct backref_cache *cache, static void remove_backref_node(struct btrfs_backref_cache *cache,
struct backref_node *node) struct btrfs_backref_node *node)
{ {
struct backref_node *upper; struct btrfs_backref_node *upper;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
if (!node) if (!node)
return; return;
BUG_ON(!node->lowest && !node->detached); BUG_ON(!node->lowest && !node->detached);
while (!list_empty(&node->upper)) { while (!list_empty(&node->upper)) {
edge = list_entry(node->upper.next, struct backref_edge, edge = list_entry(node->upper.next, struct btrfs_backref_edge,
list[LOWER]); list[LOWER]);
upper = edge->node[UPPER]; upper = edge->node[UPPER];
list_del(&edge->list[LOWER]); list_del(&edge->list[LOWER]);
...@@ -579,8 +581,8 @@ static void remove_backref_node(struct backref_cache *cache, ...@@ -579,8 +581,8 @@ static void remove_backref_node(struct backref_cache *cache,
drop_backref_node(cache, node); drop_backref_node(cache, node);
} }
static void update_backref_node(struct backref_cache *cache, static void update_backref_node(struct btrfs_backref_cache *cache,
struct backref_node *node, u64 bytenr) struct btrfs_backref_node *node, u64 bytenr)
{ {
struct rb_node *rb_node; struct rb_node *rb_node;
rb_erase(&node->rb_node, &cache->rb_root); rb_erase(&node->rb_node, &cache->rb_root);
...@@ -594,9 +596,9 @@ static void update_backref_node(struct backref_cache *cache, ...@@ -594,9 +596,9 @@ static void update_backref_node(struct backref_cache *cache,
* update backref cache after a transaction commit * update backref cache after a transaction commit
*/ */
static int update_backref_cache(struct btrfs_trans_handle *trans, static int update_backref_cache(struct btrfs_trans_handle *trans,
struct backref_cache *cache) struct btrfs_backref_cache *cache)
{ {
struct backref_node *node; struct btrfs_backref_node *node;
int level = 0; int level = 0;
if (cache->last_trans == 0) { if (cache->last_trans == 0) {
...@@ -614,13 +616,13 @@ static int update_backref_cache(struct btrfs_trans_handle *trans, ...@@ -614,13 +616,13 @@ static int update_backref_cache(struct btrfs_trans_handle *trans,
*/ */
while (!list_empty(&cache->detached)) { while (!list_empty(&cache->detached)) {
node = list_entry(cache->detached.next, node = list_entry(cache->detached.next,
struct backref_node, list); struct btrfs_backref_node, list);
remove_backref_node(cache, node); remove_backref_node(cache, node);
} }
while (!list_empty(&cache->changed)) { while (!list_empty(&cache->changed)) {
node = list_entry(cache->changed.next, node = list_entry(cache->changed.next,
struct backref_node, list); struct btrfs_backref_node, list);
list_del_init(&node->list); list_del_init(&node->list);
BUG_ON(node->pending); BUG_ON(node->pending);
update_backref_node(cache, node, node->new_bytenr); update_backref_node(cache, node, node->new_bytenr);
...@@ -743,12 +745,12 @@ static struct btrfs_root *read_fs_root(struct btrfs_fs_info *fs_info, ...@@ -743,12 +745,12 @@ static struct btrfs_root *read_fs_root(struct btrfs_fs_info *fs_info,
* type is btrfs_inline_ref_type, offset is * type is btrfs_inline_ref_type, offset is
* btrfs_inline_ref_offset. * btrfs_inline_ref_offset.
*/ */
static int handle_direct_tree_backref(struct backref_cache *cache, static int handle_direct_tree_backref(struct btrfs_backref_cache *cache,
struct btrfs_key *ref_key, struct btrfs_key *ref_key,
struct backref_node *cur) struct btrfs_backref_node *cur)
{ {
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_node *upper; struct btrfs_backref_node *upper;
struct rb_node *rb_node; struct rb_node *rb_node;
ASSERT(ref_key->type == BTRFS_SHARED_BLOCK_REF_KEY); ASSERT(ref_key->type == BTRFS_SHARED_BLOCK_REF_KEY);
...@@ -795,7 +797,7 @@ static int handle_direct_tree_backref(struct backref_cache *cache, ...@@ -795,7 +797,7 @@ static int handle_direct_tree_backref(struct backref_cache *cache,
list_add_tail(&edge->list[UPPER], &cache->pending_edge); list_add_tail(&edge->list[UPPER], &cache->pending_edge);
} else { } else {
/* Parent node already cached */ /* Parent node already cached */
upper = rb_entry(rb_node, struct backref_node, rb_node); upper = rb_entry(rb_node, struct btrfs_backref_node, rb_node);
ASSERT(upper->checked); ASSERT(upper->checked);
INIT_LIST_HEAD(&edge->list[UPPER]); INIT_LIST_HEAD(&edge->list[UPPER]);
} }
...@@ -815,16 +817,16 @@ static int handle_direct_tree_backref(struct backref_cache *cache, ...@@ -815,16 +817,16 @@ static int handle_direct_tree_backref(struct backref_cache *cache,
* @path: A clean (released) path, to avoid allocating path everytime * @path: A clean (released) path, to avoid allocating path everytime
* the function get called. * the function get called.
*/ */
static int handle_indirect_tree_backref(struct backref_cache *cache, static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_key *ref_key, struct btrfs_key *ref_key,
struct btrfs_key *tree_key, struct btrfs_key *tree_key,
struct backref_node *cur) struct btrfs_backref_node *cur)
{ {
struct btrfs_fs_info *fs_info = cache->fs_info; struct btrfs_fs_info *fs_info = cache->fs_info;
struct backref_node *upper; struct btrfs_backref_node *upper;
struct backref_node *lower; struct btrfs_backref_node *lower;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct extent_buffer *eb; struct extent_buffer *eb;
struct btrfs_root *root; struct btrfs_root *root;
struct rb_node *rb_node; struct rb_node *rb_node;
...@@ -937,7 +939,8 @@ static int handle_indirect_tree_backref(struct backref_cache *cache, ...@@ -937,7 +939,8 @@ static int handle_indirect_tree_backref(struct backref_cache *cache,
INIT_LIST_HEAD(&edge->list[UPPER]); INIT_LIST_HEAD(&edge->list[UPPER]);
} }
} else { } else {
upper = rb_entry(rb_node, struct backref_node, rb_node); upper = rb_entry(rb_node, struct btrfs_backref_node,
rb_node);
ASSERT(upper->checked); ASSERT(upper->checked);
INIT_LIST_HEAD(&edge->list[UPPER]); INIT_LIST_HEAD(&edge->list[UPPER]);
if (!upper->owner) if (!upper->owner)
...@@ -957,15 +960,15 @@ static int handle_indirect_tree_backref(struct backref_cache *cache, ...@@ -957,15 +960,15 @@ static int handle_indirect_tree_backref(struct backref_cache *cache,
return ret; return ret;
} }
static int handle_one_tree_block(struct backref_cache *cache, static int handle_one_tree_block(struct btrfs_backref_cache *cache,
struct btrfs_path *path, struct btrfs_path *path,
struct btrfs_backref_iter *iter, struct btrfs_backref_iter *iter,
struct btrfs_key *node_key, struct btrfs_key *node_key,
struct backref_node *cur) struct btrfs_backref_node *cur)
{ {
struct btrfs_fs_info *fs_info = cache->fs_info; struct btrfs_fs_info *fs_info = cache->fs_info;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_node *exist; struct btrfs_backref_node *exist;
int ret; int ret;
ret = btrfs_backref_iter_start(iter, cur->bytenr); ret = btrfs_backref_iter_start(iter, cur->bytenr);
...@@ -992,7 +995,7 @@ static int handle_one_tree_block(struct backref_cache *cache, ...@@ -992,7 +995,7 @@ static int handle_one_tree_block(struct backref_cache *cache,
* backref of type BTRFS_TREE_BLOCK_REF_KEY * backref of type BTRFS_TREE_BLOCK_REF_KEY
*/ */
ASSERT(list_is_singular(&cur->upper)); ASSERT(list_is_singular(&cur->upper));
edge = list_entry(cur->upper.next, struct backref_edge, edge = list_entry(cur->upper.next, struct btrfs_backref_edge,
list[LOWER]); list[LOWER]);
ASSERT(list_empty(&edge->list[UPPER])); ASSERT(list_empty(&edge->list[UPPER]));
exist = edge->node[UPPER]; exist = edge->node[UPPER];
...@@ -1083,19 +1086,20 @@ static int handle_one_tree_block(struct backref_cache *cache, ...@@ -1083,19 +1086,20 @@ static int handle_one_tree_block(struct backref_cache *cache,
/* /*
* In handle_one_tree_backref(), we have only linked the lower node to the edge, * In handle_one_tree_backref(), we have only linked the lower node to the edge,
* but the upper node hasn't been linked to the edge. * but the upper node hasn't been linked to the edge.
* This means we can only iterate through backref_node::upper to reach parent * This means we can only iterate through btrfs_backref_node::upper to reach
* edges, but not through backref_node::lower to reach children edges. * parent edges, but not through btrfs_backref_node::lower to reach children
* edges.
* *
* This function will finish the backref_node::lower to related edges, so that * This function will finish the btrfs_backref_node::lower to related edges,
* backref cache can be bi-directionally iterated. * so that backref cache can be bi-directionally iterated.
* *
* Also, this will add the nodes to backref cache for the next run. * Also, this will add the nodes to backref cache for the next run.
*/ */
static int finish_upper_links(struct backref_cache *cache, static int finish_upper_links(struct btrfs_backref_cache *cache,
struct backref_node *start) struct btrfs_backref_node *start)
{ {
struct list_head *useless_node = &cache->useless_node; struct list_head *useless_node = &cache->useless_node;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct rb_node *rb_node; struct rb_node *rb_node;
LIST_HEAD(pending_edge); LIST_HEAD(pending_edge);
...@@ -1119,12 +1123,12 @@ static int finish_upper_links(struct backref_cache *cache, ...@@ -1119,12 +1123,12 @@ static int finish_upper_links(struct backref_cache *cache,
list_add_tail(&edge->list[UPPER], &pending_edge); list_add_tail(&edge->list[UPPER], &pending_edge);
while (!list_empty(&pending_edge)) { while (!list_empty(&pending_edge)) {
struct backref_node *upper; struct btrfs_backref_node *upper;
struct backref_node *lower; struct btrfs_backref_node *lower;
struct rb_node *rb_node; struct rb_node *rb_node;
edge = list_first_entry(&pending_edge, struct backref_edge, edge = list_first_entry(&pending_edge,
list[UPPER]); struct btrfs_backref_edge, list[UPPER]);
list_del_init(&edge->list[UPPER]); list_del_init(&edge->list[UPPER]);
upper = edge->node[UPPER]; upper = edge->node[UPPER];
lower = edge->node[LOWER]; lower = edge->node[LOWER];
...@@ -1206,16 +1210,16 @@ static int finish_upper_links(struct backref_cache *cache, ...@@ -1206,16 +1210,16 @@ static int finish_upper_links(struct backref_cache *cache,
* Return true if @node is in the @useless_nodes list. * Return true if @node is in the @useless_nodes list.
*/ */
static bool handle_useless_nodes(struct reloc_control *rc, static bool handle_useless_nodes(struct reloc_control *rc,
struct backref_node *node) struct btrfs_backref_node *node)
{ {
struct backref_cache *cache = &rc->backref_cache; struct btrfs_backref_cache *cache = &rc->backref_cache;
struct list_head *useless_node = &cache->useless_node; struct list_head *useless_node = &cache->useless_node;
bool ret = false; bool ret = false;
while (!list_empty(useless_node)) { while (!list_empty(useless_node)) {
struct backref_node *cur; struct btrfs_backref_node *cur;
cur = list_first_entry(useless_node, struct backref_node, cur = list_first_entry(useless_node, struct btrfs_backref_node,
list); list);
list_del_init(&cur->list); list_del_init(&cur->list);
...@@ -1233,11 +1237,11 @@ static bool handle_useless_nodes(struct reloc_control *rc, ...@@ -1233,11 +1237,11 @@ static bool handle_useless_nodes(struct reloc_control *rc,
/* Cleanup the lower edges */ /* Cleanup the lower edges */
while (!list_empty(&cur->lower)) { while (!list_empty(&cur->lower)) {
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_node *lower; struct btrfs_backref_node *lower;
edge = list_entry(cur->lower.next, edge = list_entry(cur->lower.next,
struct backref_edge, list[UPPER]); struct btrfs_backref_edge, list[UPPER]);
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];
...@@ -1280,19 +1284,19 @@ static bool handle_useless_nodes(struct reloc_control *rc, ...@@ -1280,19 +1284,19 @@ static bool handle_useless_nodes(struct reloc_control *rc,
* all upper level blocks that directly/indirectly reference the block are also * all upper level blocks that directly/indirectly reference the block are also
* cached. * cached.
*/ */
static noinline_for_stack struct backref_node *build_backref_tree( static noinline_for_stack struct btrfs_backref_node *build_backref_tree(
struct reloc_control *rc, struct btrfs_key *node_key, struct reloc_control *rc, struct btrfs_key *node_key,
int level, u64 bytenr) int level, u64 bytenr)
{ {
struct btrfs_backref_iter *iter; struct btrfs_backref_iter *iter;
struct backref_cache *cache = &rc->backref_cache; struct btrfs_backref_cache *cache = &rc->backref_cache;
/* For searching parent of TREE_BLOCK_REF */ /* For searching parent of TREE_BLOCK_REF */
struct btrfs_path *path; struct btrfs_path *path;
struct backref_node *cur; struct btrfs_backref_node *cur;
struct backref_node *upper; struct btrfs_backref_node *upper;
struct backref_node *lower; struct btrfs_backref_node *lower;
struct backref_node *node = NULL; struct btrfs_backref_node *node = NULL;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
int ret; int ret;
int err = 0; int err = 0;
...@@ -1322,7 +1326,7 @@ static noinline_for_stack struct backref_node *build_backref_tree( ...@@ -1322,7 +1326,7 @@ static noinline_for_stack struct backref_node *build_backref_tree(
goto out; goto out;
} }
edge = list_first_entry_or_null(&cache->pending_edge, edge = list_first_entry_or_null(&cache->pending_edge,
struct backref_edge, list[UPPER]); struct btrfs_backref_edge, list[UPPER]);
/* /*
* The pending list isn't empty, take the first block to * The pending list isn't empty, take the first block to
* process * process
...@@ -1348,12 +1352,12 @@ static noinline_for_stack struct backref_node *build_backref_tree( ...@@ -1348,12 +1352,12 @@ static noinline_for_stack struct backref_node *build_backref_tree(
if (err) { if (err) {
while (!list_empty(&cache->useless_node)) { while (!list_empty(&cache->useless_node)) {
lower = list_first_entry(&cache->useless_node, lower = list_first_entry(&cache->useless_node,
struct backref_node, list); struct btrfs_backref_node, list);
list_del_init(&lower->list); list_del_init(&lower->list);
} }
while (!list_empty(&cache->pending_edge)) { while (!list_empty(&cache->pending_edge)) {
edge = list_first_entry(&cache->pending_edge, edge = list_first_entry(&cache->pending_edge,
struct backref_edge, list[UPPER]); struct btrfs_backref_edge, list[UPPER]);
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];
...@@ -1381,7 +1385,7 @@ static noinline_for_stack struct backref_node *build_backref_tree( ...@@ -1381,7 +1385,7 @@ static noinline_for_stack struct backref_node *build_backref_tree(
while (!list_empty(&cache->useless_node)) { while (!list_empty(&cache->useless_node)) {
lower = list_first_entry(&cache->useless_node, lower = list_first_entry(&cache->useless_node,
struct backref_node, list); struct btrfs_backref_node, list);
list_del_init(&lower->list); list_del_init(&lower->list);
if (lower == node) if (lower == node)
node = NULL; node = NULL;
...@@ -1410,11 +1414,11 @@ static int clone_backref_node(struct btrfs_trans_handle *trans, ...@@ -1410,11 +1414,11 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
struct btrfs_root *dest) struct btrfs_root *dest)
{ {
struct btrfs_root *reloc_root = src->reloc_root; struct btrfs_root *reloc_root = src->reloc_root;
struct backref_cache *cache = &rc->backref_cache; struct btrfs_backref_cache *cache = &rc->backref_cache;
struct backref_node *node = NULL; struct btrfs_backref_node *node = NULL;
struct backref_node *new_node; struct btrfs_backref_node *new_node;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_edge *new_edge; struct btrfs_backref_edge *new_edge;
struct rb_node *rb_node; struct rb_node *rb_node;
if (cache->last_trans > 0) if (cache->last_trans > 0)
...@@ -1422,7 +1426,7 @@ static int clone_backref_node(struct btrfs_trans_handle *trans, ...@@ -1422,7 +1426,7 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
rb_node = tree_search(&cache->rb_root, src->commit_root->start); rb_node = tree_search(&cache->rb_root, src->commit_root->start);
if (rb_node) { if (rb_node) {
node = rb_entry(rb_node, struct backref_node, rb_node); node = rb_entry(rb_node, struct btrfs_backref_node, rb_node);
if (node->detached) if (node->detached)
node = NULL; node = NULL;
else else
...@@ -1433,7 +1437,7 @@ static int clone_backref_node(struct btrfs_trans_handle *trans, ...@@ -1433,7 +1437,7 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
rb_node = tree_search(&cache->rb_root, rb_node = tree_search(&cache->rb_root,
reloc_root->commit_root->start); reloc_root->commit_root->start);
if (rb_node) { if (rb_node) {
node = rb_entry(rb_node, struct backref_node, node = rb_entry(rb_node, struct btrfs_backref_node,
rb_node); rb_node);
BUG_ON(node->detached); BUG_ON(node->detached);
} }
...@@ -1479,7 +1483,7 @@ static int clone_backref_node(struct btrfs_trans_handle *trans, ...@@ -1479,7 +1483,7 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
fail: fail:
while (!list_empty(&new_node->lower)) { while (!list_empty(&new_node->lower)) {
new_edge = list_entry(new_node->lower.next, new_edge = list_entry(new_node->lower.next,
struct 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); free_backref_edge(cache, new_edge);
} }
...@@ -2869,10 +2873,10 @@ static int record_reloc_root_in_trans(struct btrfs_trans_handle *trans, ...@@ -2869,10 +2873,10 @@ static int record_reloc_root_in_trans(struct btrfs_trans_handle *trans,
static noinline_for_stack static noinline_for_stack
struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans, struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
struct reloc_control *rc, struct reloc_control *rc,
struct backref_node *node, struct btrfs_backref_node *node,
struct backref_edge *edges[]) struct btrfs_backref_edge *edges[])
{ {
struct backref_node *next; struct btrfs_backref_node *next;
struct btrfs_root *root; struct btrfs_root *root;
int index = 0; int index = 0;
...@@ -2932,12 +2936,12 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans, ...@@ -2932,12 +2936,12 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
* counted. return -ENOENT if the block is root of reloc tree. * counted. return -ENOENT if the block is root of reloc tree.
*/ */
static noinline_for_stack static noinline_for_stack
struct btrfs_root *select_one_root(struct backref_node *node) struct btrfs_root *select_one_root(struct btrfs_backref_node *node)
{ {
struct backref_node *next; struct btrfs_backref_node *next;
struct btrfs_root *root; struct btrfs_root *root;
struct btrfs_root *fs_root = NULL; struct btrfs_root *fs_root = NULL;
struct backref_edge *edges[BTRFS_MAX_LEVEL - 1]; struct btrfs_backref_edge *edges[BTRFS_MAX_LEVEL - 1];
int index = 0; int index = 0;
next = node; next = node;
...@@ -2969,12 +2973,12 @@ struct btrfs_root *select_one_root(struct backref_node *node) ...@@ -2969,12 +2973,12 @@ struct btrfs_root *select_one_root(struct backref_node *node)
static noinline_for_stack static noinline_for_stack
u64 calcu_metadata_size(struct reloc_control *rc, u64 calcu_metadata_size(struct reloc_control *rc,
struct backref_node *node, int reserve) struct btrfs_backref_node *node, int reserve)
{ {
struct btrfs_fs_info *fs_info = rc->extent_root->fs_info; struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;
struct backref_node *next = node; struct btrfs_backref_node *next = node;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_edge *edges[BTRFS_MAX_LEVEL - 1]; struct btrfs_backref_edge *edges[BTRFS_MAX_LEVEL - 1];
u64 num_bytes = 0; u64 num_bytes = 0;
int index = 0; int index = 0;
...@@ -2992,7 +2996,7 @@ u64 calcu_metadata_size(struct reloc_control *rc, ...@@ -2992,7 +2996,7 @@ u64 calcu_metadata_size(struct reloc_control *rc,
break; break;
edge = list_entry(next->upper.next, edge = list_entry(next->upper.next,
struct backref_edge, list[LOWER]); struct btrfs_backref_edge, list[LOWER]);
edges[index++] = edge; edges[index++] = edge;
next = edge->node[UPPER]; next = edge->node[UPPER];
} }
...@@ -3003,7 +3007,7 @@ u64 calcu_metadata_size(struct reloc_control *rc, ...@@ -3003,7 +3007,7 @@ u64 calcu_metadata_size(struct reloc_control *rc,
static int reserve_metadata_space(struct btrfs_trans_handle *trans, static int reserve_metadata_space(struct btrfs_trans_handle *trans,
struct reloc_control *rc, struct reloc_control *rc,
struct backref_node *node) struct btrfs_backref_node *node)
{ {
struct btrfs_root *root = rc->extent_root; struct btrfs_root *root = rc->extent_root;
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
...@@ -3051,14 +3055,14 @@ static int reserve_metadata_space(struct btrfs_trans_handle *trans, ...@@ -3051,14 +3055,14 @@ static int reserve_metadata_space(struct btrfs_trans_handle *trans,
*/ */
static int do_relocation(struct btrfs_trans_handle *trans, static int do_relocation(struct btrfs_trans_handle *trans,
struct reloc_control *rc, struct reloc_control *rc,
struct backref_node *node, struct btrfs_backref_node *node,
struct btrfs_key *key, struct btrfs_key *key,
struct btrfs_path *path, int lowest) struct btrfs_path *path, int lowest)
{ {
struct btrfs_fs_info *fs_info = rc->extent_root->fs_info; struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;
struct backref_node *upper; struct btrfs_backref_node *upper;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_edge *edges[BTRFS_MAX_LEVEL - 1]; struct btrfs_backref_edge *edges[BTRFS_MAX_LEVEL - 1];
struct btrfs_root *root; struct btrfs_root *root;
struct extent_buffer *eb; struct extent_buffer *eb;
u32 blocksize; u32 blocksize;
...@@ -3214,7 +3218,7 @@ static int do_relocation(struct btrfs_trans_handle *trans, ...@@ -3214,7 +3218,7 @@ static int do_relocation(struct btrfs_trans_handle *trans,
static int link_to_upper(struct btrfs_trans_handle *trans, static int link_to_upper(struct btrfs_trans_handle *trans,
struct reloc_control *rc, struct reloc_control *rc,
struct backref_node *node, struct btrfs_backref_node *node,
struct btrfs_path *path) struct btrfs_path *path)
{ {
struct btrfs_key key; struct btrfs_key key;
...@@ -3228,15 +3232,15 @@ static int finish_pending_nodes(struct btrfs_trans_handle *trans, ...@@ -3228,15 +3232,15 @@ static int finish_pending_nodes(struct btrfs_trans_handle *trans,
struct btrfs_path *path, int err) struct btrfs_path *path, int err)
{ {
LIST_HEAD(list); LIST_HEAD(list);
struct backref_cache *cache = &rc->backref_cache; struct btrfs_backref_cache *cache = &rc->backref_cache;
struct backref_node *node; struct btrfs_backref_node *node;
int level; int level;
int ret; int ret;
for (level = 0; level < BTRFS_MAX_LEVEL; level++) { for (level = 0; level < BTRFS_MAX_LEVEL; level++) {
while (!list_empty(&cache->pending[level])) { while (!list_empty(&cache->pending[level])) {
node = list_entry(cache->pending[level].next, node = list_entry(cache->pending[level].next,
struct backref_node, list); struct btrfs_backref_node, list);
list_move_tail(&node->list, &list); list_move_tail(&node->list, &list);
BUG_ON(!node->pending); BUG_ON(!node->pending);
...@@ -3256,11 +3260,11 @@ static int finish_pending_nodes(struct btrfs_trans_handle *trans, ...@@ -3256,11 +3260,11 @@ static int finish_pending_nodes(struct btrfs_trans_handle *trans,
* as processed. * as processed.
*/ */
static void update_processed_blocks(struct reloc_control *rc, static void update_processed_blocks(struct reloc_control *rc,
struct backref_node *node) struct btrfs_backref_node *node)
{ {
struct backref_node *next = node; struct btrfs_backref_node *next = node;
struct backref_edge *edge; struct btrfs_backref_edge *edge;
struct backref_edge *edges[BTRFS_MAX_LEVEL - 1]; struct btrfs_backref_edge *edges[BTRFS_MAX_LEVEL - 1];
int index = 0; int index = 0;
while (next) { while (next) {
...@@ -3275,7 +3279,7 @@ static void update_processed_blocks(struct reloc_control *rc, ...@@ -3275,7 +3279,7 @@ static void update_processed_blocks(struct reloc_control *rc,
break; break;
edge = list_entry(next->upper.next, edge = list_entry(next->upper.next,
struct backref_edge, list[LOWER]); struct btrfs_backref_edge, list[LOWER]);
edges[index++] = edge; edges[index++] = edge;
next = edge->node[UPPER]; next = edge->node[UPPER];
} }
...@@ -3320,7 +3324,7 @@ static int get_tree_block_key(struct btrfs_fs_info *fs_info, ...@@ -3320,7 +3324,7 @@ static int get_tree_block_key(struct btrfs_fs_info *fs_info,
*/ */
static int relocate_tree_block(struct btrfs_trans_handle *trans, static int relocate_tree_block(struct btrfs_trans_handle *trans,
struct reloc_control *rc, struct reloc_control *rc,
struct backref_node *node, struct btrfs_backref_node *node,
struct btrfs_key *key, struct btrfs_key *key,
struct btrfs_path *path) struct btrfs_path *path)
{ {
...@@ -3382,7 +3386,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans, ...@@ -3382,7 +3386,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
struct reloc_control *rc, struct rb_root *blocks) struct reloc_control *rc, struct rb_root *blocks)
{ {
struct btrfs_fs_info *fs_info = rc->extent_root->fs_info; struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;
struct backref_node *node; struct btrfs_backref_node *node;
struct btrfs_path *path; struct btrfs_path *path;
struct tree_block *block; struct tree_block *block;
struct tree_block *next; struct tree_block *next;
...@@ -4802,7 +4806,7 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans, ...@@ -4802,7 +4806,7 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct reloc_control *rc; struct reloc_control *rc;
struct backref_node *node; struct btrfs_backref_node *node;
int first_cow = 0; int first_cow = 0;
int level; int level;
int ret = 0; int ret = 0;
......
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