btrfs-progs: Refactor btrfs_find_tree_block to use btrfs_fs_info

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Qu Wenruo 2017-06-13 17:19:25 +08:00 committed by David Sterba
parent b350e8fd76
commit 6aaf1b10e7
5 changed files with 17 additions and 14 deletions

View File

@ -2104,6 +2104,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
enum btrfs_tree_block_status status;
u64 bytenr;
u64 ptr_gen;
struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_buffer *next;
struct extent_buffer *cur;
u32 blocksize;
@ -2155,7 +2156,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
}
bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
blocksize = root->fs_info->nodesize;
blocksize = fs_info->nodesize;
if (bytenr == nrefs->bytenr[*level - 1]) {
refs = nrefs->refs[*level - 1];
@ -2179,7 +2180,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
}
}
next = btrfs_find_tree_block(root, bytenr, blocksize);
next = btrfs_find_tree_block(fs_info, bytenr, blocksize);
if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
free_extent_buffer(next);
reada_walk_down(root, cur, path->slots[*level]);
@ -2242,6 +2243,7 @@ static int walk_down_tree_v2(struct btrfs_root *root, struct btrfs_path *path,
enum btrfs_tree_block_status status;
u64 bytenr;
u64 ptr_gen;
struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_buffer *next;
struct extent_buffer *cur;
u32 blocksize;
@ -2284,7 +2286,7 @@ static int walk_down_tree_v2(struct btrfs_root *root, struct btrfs_path *path,
}
bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
blocksize = root->fs_info->nodesize;
blocksize = fs_info->nodesize;
ret = update_nodes_refs(root, bytenr, nrefs, *level - 1);
if (ret)
@ -2294,11 +2296,11 @@ static int walk_down_tree_v2(struct btrfs_root *root, struct btrfs_path *path,
continue;
}
next = btrfs_find_tree_block(root, bytenr, blocksize);
next = btrfs_find_tree_block(fs_info, bytenr, blocksize);
if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
free_extent_buffer(next);
reada_walk_down(root, cur, path->slots[*level]);
next = read_tree_block(root->fs_info, bytenr, blocksize,
next = read_tree_block(fs_info, bytenr, blocksize,
ptr_gen);
if (!extent_buffer_uptodate(next)) {
struct btrfs_key node_key;
@ -2306,10 +2308,10 @@ static int walk_down_tree_v2(struct btrfs_root *root, struct btrfs_path *path,
btrfs_node_key_to_cpu(path->nodes[*level],
&node_key,
path->slots[*level]);
btrfs_add_corrupt_extent_record(root->fs_info,
btrfs_add_corrupt_extent_record(fs_info,
&node_key,
path->nodes[*level]->start,
root->fs_info->nodesize,
fs_info->nodesize,
*level);
ret = -EIO;
break;

View File

@ -968,6 +968,7 @@ static int noinline push_nodes_for_insert(struct btrfs_trans_handle *trans,
void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
int level, int slot, u64 objectid)
{
struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_buffer *node;
struct btrfs_disk_key disk_key;
u32 nritems;
@ -989,8 +990,8 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
node = path->nodes[level];
search = btrfs_node_blockptr(node, slot);
blocksize = root->fs_info->nodesize;
eb = btrfs_find_tree_block(root, search, blocksize);
blocksize = fs_info->nodesize;
eb = btrfs_find_tree_block(fs_info, search, blocksize);
if (eb) {
free_extent_buffer(eb);
return;

View File

@ -174,10 +174,10 @@ int csum_tree_block(struct btrfs_fs_info *fs_info,
return csum_tree_block_size(buf, csum_size, verify);
}
struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
struct extent_buffer *btrfs_find_tree_block(struct btrfs_fs_info *fs_info,
u64 bytenr, u32 blocksize)
{
return find_extent_buffer(&root->fs_info->extent_cache,
return find_extent_buffer(&fs_info->extent_cache,
bytenr, blocksize);
}
@ -195,7 +195,7 @@ void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
struct btrfs_multi_bio *multi = NULL;
struct btrfs_device *device;
eb = btrfs_find_tree_block(root, bytenr, blocksize);
eb = btrfs_find_tree_block(root->fs_info, bytenr, blocksize);
if (!(eb && btrfs_buffer_uptodate(eb, parent_transid)) &&
!btrfs_map_block(root->fs_info, READ, bytenr, &length, &multi, 0,
NULL)) {

View File

@ -168,7 +168,7 @@ int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr,
unsigned sbflags);
int btrfs_map_bh_to_logical(struct btrfs_root *root, struct extent_buffer *bh,
u64 logical);
struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
struct extent_buffer *btrfs_find_tree_block(struct btrfs_fs_info *fs_info,
u64 bytenr, u32 blocksize);
struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
struct btrfs_key *location);

View File

@ -2119,7 +2119,7 @@ static int pin_down_bytes(struct btrfs_trans_handle *trans,
if (is_data)
goto pinit;
buf = btrfs_find_tree_block(root, bytenr, num_bytes);
buf = btrfs_find_tree_block(root->fs_info, bytenr, num_bytes);
if (!buf)
goto pinit;