提交 02873e43 编写于 作者: Z Zhao Lei 提交者: David Sterba

btrfs: reada: Use fs_info instead of root in __readahead_hook's argument

What __readahead_hook() need exactly is fs_info, no need to convert
fs_info to root in caller and convert back in __readahead_hook()
Signed-off-by: NZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 6e39dbe8
...@@ -4525,8 +4525,8 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root, ...@@ -4525,8 +4525,8 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
struct btrfs_key *start, struct btrfs_key *end); struct btrfs_key *start, struct btrfs_key *end);
int btrfs_reada_wait(void *handle); int btrfs_reada_wait(void *handle);
void btrfs_reada_detach(void *handle); void btrfs_reada_detach(void *handle);
int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb, int btree_readahead_hook(struct btrfs_fs_info *fs_info,
u64 start, int err); struct extent_buffer *eb, u64 start, int err);
static inline int is_fstree(u64 rootid) static inline int is_fstree(u64 rootid)
{ {
......
...@@ -612,6 +612,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, ...@@ -612,6 +612,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
int found_level; int found_level;
struct extent_buffer *eb; struct extent_buffer *eb;
struct btrfs_root *root = BTRFS_I(page->mapping->host)->root; struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
struct btrfs_fs_info *fs_info = root->fs_info;
int ret = 0; int ret = 0;
int reads_done; int reads_done;
...@@ -637,20 +638,20 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, ...@@ -637,20 +638,20 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
found_start = btrfs_header_bytenr(eb); found_start = btrfs_header_bytenr(eb);
if (found_start != eb->start) { if (found_start != eb->start) {
btrfs_err_rl(eb->fs_info, "bad tree block start %llu %llu", btrfs_err_rl(fs_info, "bad tree block start %llu %llu",
found_start, eb->start); found_start, eb->start);
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
if (check_tree_block_fsid(root->fs_info, eb)) { if (check_tree_block_fsid(fs_info, eb)) {
btrfs_err_rl(eb->fs_info, "bad fsid on block %llu", btrfs_err_rl(fs_info, "bad fsid on block %llu",
eb->start); eb->start);
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
found_level = btrfs_header_level(eb); found_level = btrfs_header_level(eb);
if (found_level >= BTRFS_MAX_LEVEL) { if (found_level >= BTRFS_MAX_LEVEL) {
btrfs_err(root->fs_info, "bad tree block level %d", btrfs_err(fs_info, "bad tree block level %d",
(int)btrfs_header_level(eb)); (int)btrfs_header_level(eb));
ret = -EIO; ret = -EIO;
goto err; goto err;
...@@ -659,7 +660,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, ...@@ -659,7 +660,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb), btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb),
eb, found_level); eb, found_level);
ret = csum_tree_block(root->fs_info, eb, 1); ret = csum_tree_block(fs_info, eb, 1);
if (ret) { if (ret) {
ret = -EIO; ret = -EIO;
goto err; goto err;
...@@ -680,7 +681,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, ...@@ -680,7 +681,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
err: err:
if (reads_done && if (reads_done &&
test_and_clear_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags)) test_and_clear_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags))
btree_readahead_hook(root, eb, eb->start, ret); btree_readahead_hook(fs_info, eb, eb->start, ret);
if (ret) { if (ret) {
/* /*
...@@ -699,14 +700,13 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, ...@@ -699,14 +700,13 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
static int btree_io_failed_hook(struct page *page, int failed_mirror) static int btree_io_failed_hook(struct page *page, int failed_mirror)
{ {
struct extent_buffer *eb; struct extent_buffer *eb;
struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
eb = (struct extent_buffer *)page->private; eb = (struct extent_buffer *)page->private;
set_bit(EXTENT_BUFFER_READ_ERR, &eb->bflags); set_bit(EXTENT_BUFFER_READ_ERR, &eb->bflags);
eb->read_mirror = failed_mirror; eb->read_mirror = failed_mirror;
atomic_dec(&eb->io_pages); atomic_dec(&eb->io_pages);
if (test_and_clear_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags)) if (test_and_clear_bit(EXTENT_BUFFER_READAHEAD, &eb->bflags))
btree_readahead_hook(root, eb, eb->start, -EIO); btree_readahead_hook(eb->fs_info, eb, eb->start, -EIO);
return -EIO; /* we fixed nothing */ return -EIO; /* we fixed nothing */
} }
......
...@@ -105,15 +105,15 @@ static int reada_add_block(struct reada_control *rc, u64 logical, ...@@ -105,15 +105,15 @@ static int reada_add_block(struct reada_control *rc, u64 logical,
/* recurses */ /* recurses */
/* in case of err, eb might be NULL */ /* in case of err, eb might be NULL */
static void __readahead_hook(struct btrfs_root *root, struct reada_extent *re, static void __readahead_hook(struct btrfs_fs_info *fs_info,
struct extent_buffer *eb, u64 start, int err) struct reada_extent *re, struct extent_buffer *eb,
u64 start, int err)
{ {
int level = 0; int level = 0;
int nritems; int nritems;
int i; int i;
u64 bytenr; u64 bytenr;
u64 generation; u64 generation;
struct btrfs_fs_info *fs_info = root->fs_info;
struct list_head list; struct list_head list;
struct btrfs_device *for_dev; struct btrfs_device *for_dev;
...@@ -176,7 +176,7 @@ static void __readahead_hook(struct btrfs_root *root, struct reada_extent *re, ...@@ -176,7 +176,7 @@ static void __readahead_hook(struct btrfs_root *root, struct reada_extent *re,
*/ */
#ifdef DEBUG #ifdef DEBUG
if (rec->generation != generation) { if (rec->generation != generation) {
btrfs_debug(root->fs_info, btrfs_debug(fs_info,
"generation mismatch for (%llu,%d,%llu) %llu != %llu", "generation mismatch for (%llu,%d,%llu) %llu != %llu",
key.objectid, key.type, key.offset, key.objectid, key.type, key.offset,
rec->generation, generation); rec->generation, generation);
...@@ -220,12 +220,11 @@ static void __readahead_hook(struct btrfs_root *root, struct reada_extent *re, ...@@ -220,12 +220,11 @@ static void __readahead_hook(struct btrfs_root *root, struct reada_extent *re,
* start is passed separately in case eb in NULL, which may be the case with * start is passed separately in case eb in NULL, which may be the case with
* failed I/O * failed I/O
*/ */
int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb, int btree_readahead_hook(struct btrfs_fs_info *fs_info,
u64 start, int err) struct extent_buffer *eb, u64 start, int err)
{ {
int ret = 0; int ret = 0;
struct reada_extent *re; struct reada_extent *re;
struct btrfs_fs_info *fs_info = root->fs_info;
/* find extent */ /* find extent */
spin_lock(&fs_info->reada_lock); spin_lock(&fs_info->reada_lock);
...@@ -724,9 +723,9 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, ...@@ -724,9 +723,9 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
ret = reada_tree_block_flagged(fs_info->extent_root, logical, ret = reada_tree_block_flagged(fs_info->extent_root, logical,
mirror_num, &eb); mirror_num, &eb);
if (ret) if (ret)
__readahead_hook(fs_info->extent_root, re, NULL, logical, ret); __readahead_hook(fs_info, re, NULL, logical, ret);
else if (eb) else if (eb)
__readahead_hook(fs_info->extent_root, re, eb, eb->start, ret); __readahead_hook(fs_info, re, eb, eb->start, ret);
if (eb) if (eb)
free_extent_buffer(eb); free_extent_buffer(eb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册