btrfs-progs: Refactor btrfs_readahead_tree_block to use btrfs_fs_info

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2017-06-13 17:19:26 +08:00 committed by David Sterba
parent 6aaf1b10e7
commit bb3ecd59f2
5 changed files with 13 additions and 11 deletions

View File

@ -1967,6 +1967,7 @@ out:
static void reada_walk_down(struct btrfs_root *root,
struct extent_buffer *node, int slot)
{
struct btrfs_fs_info *fs_info = root->fs_info;
u64 bytenr;
u64 ptr_gen;
u32 nritems;
@ -1979,11 +1980,11 @@ static void reada_walk_down(struct btrfs_root *root,
return;
nritems = btrfs_header_nritems(node);
blocksize = root->fs_info->nodesize;
blocksize = fs_info->nodesize;
for (i = slot; i < nritems; i++) {
bytenr = btrfs_node_blockptr(node, i);
ptr_gen = btrfs_node_ptr_generation(node, i);
readahead_tree_block(root, bytenr, blocksize, ptr_gen);
readahead_tree_block(fs_info, bytenr, blocksize, ptr_gen);
}
}
@ -7610,6 +7611,7 @@ static int run_next_block(struct btrfs_root *root,
struct device_extent_tree *dev_extent_cache,
struct root_item_record *ri)
{
struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_buffer *buf;
struct extent_record *rec = NULL;
u64 bytenr;
@ -7639,7 +7641,7 @@ static int run_next_block(struct btrfs_root *root,
continue;
/* fixme, get the parent transid */
readahead_tree_block(root, bits[i].start,
readahead_tree_block(fs_info, bits[i].start,
bits[i].size, 0);
}
}

View File

@ -1021,7 +1021,7 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
if ((search >= lowest_read && search <= highest_read) ||
(search < lowest_read && lowest_read - search <= 32768) ||
(search > highest_read && search - highest_read <= 32768)) {
readahead_tree_block(root, search, blocksize,
readahead_tree_block(fs_info, search, blocksize,
btrfs_node_ptr_generation(node, nr));
nread += blocksize;
}

View File

@ -187,17 +187,17 @@ struct extent_buffer* btrfs_find_create_tree_block(
return alloc_extent_buffer(&fs_info->extent_cache, bytenr, blocksize);
}
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
u64 parent_transid)
void readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
u32 blocksize, u64 parent_transid)
{
struct extent_buffer *eb;
u64 length;
struct btrfs_multi_bio *multi = NULL;
struct btrfs_device *device;
eb = btrfs_find_tree_block(root->fs_info, bytenr, blocksize);
eb = btrfs_find_tree_block(fs_info, bytenr, blocksize);
if (!(eb && btrfs_buffer_uptodate(eb, parent_transid)) &&
!btrfs_map_block(root->fs_info, READ, bytenr, &length, &multi, 0,
!btrfs_map_block(fs_info, READ, bytenr, &length, &multi, 0,
NULL)) {
device = multi->stripes[0].dev;
device->total_ios++;

View File

@ -121,8 +121,8 @@ struct extent_buffer* read_tree_block(
int read_extent_data(struct btrfs_fs_info *fs_info, char *data, u64 logical,
u64 *len, int mirror);
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
u64 parent_transid);
void readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
u32 blocksize, u64 parent_transid);
struct extent_buffer* btrfs_find_create_tree_block(
struct btrfs_fs_info *fs_info, u64 bytenr, u32 blocksize);

View File

@ -1029,7 +1029,7 @@ static int add_extent(u64 start, u64 size, struct metadump_struct *md,
return ret;
md->pending_start = start;
}
readahead_tree_block(md->root, start, size, 0);
readahead_tree_block(md->root->fs_info, start, size, 0);
md->pending_size += size;
md->data = data;
return 0;