btrfs: reada: Use fs_info instead of root in __readahead_hook's argument
authorZhao Lei <zhaolei@cn.fujitsu.com>
Thu, 31 Dec 2015 14:46:45 +0000 (22:46 +0800)
committerDavid Sterba <dsterba@suse.com>
Thu, 18 Feb 2016 09:26:12 +0000 (10:26 +0100)
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: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/reada.c

index bfe4a33..e557e05 100644 (file)
@@ -4525,8 +4525,8 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
                              struct btrfs_key *start, struct btrfs_key *end);
 int btrfs_reada_wait(void *handle);
 void btrfs_reada_detach(void *handle);
-int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb,
-                        u64 start, int err);
+int btree_readahead_hook(struct btrfs_fs_info *fs_info,
+                        struct extent_buffer *eb, u64 start, int err);
 
 static inline int is_fstree(u64 rootid)
 {
index 4545e2e..498156e 100644 (file)
@@ -612,6 +612,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
        int found_level;
        struct extent_buffer *eb;
        struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
+       struct btrfs_fs_info *fs_info = root->fs_info;
        int ret = 0;
        int reads_done;
 
@@ -637,21 +638,21 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
 
        found_start = btrfs_header_bytenr(eb);
        if (found_start != eb->start) {
-               btrfs_err_rl(eb->fs_info, "bad tree block start %llu %llu",
-                              found_start, eb->start);
+               btrfs_err_rl(fs_info, "bad tree block start %llu %llu",
+                            found_start, eb->start);
                ret = -EIO;
                goto err;
        }
-       if (check_tree_block_fsid(root->fs_info, eb)) {
-               btrfs_err_rl(eb->fs_info, "bad fsid on block %llu",
-                              eb->start);
+       if (check_tree_block_fsid(fs_info, eb)) {
+               btrfs_err_rl(fs_info, "bad fsid on block %llu",
+                            eb->start);
                ret = -EIO;
                goto err;
        }
        found_level = btrfs_header_level(eb);
        if (found_level >= BTRFS_MAX_LEVEL) {
-               btrfs_err(root->fs_info, "bad tree block level %d",
-                          (int)btrfs_header_level(eb));
+               btrfs_err(fs_info, "bad tree block level %d",
+                         (int)btrfs_header_level(eb));
                ret = -EIO;
                goto err;
        }
@@ -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),
                                       eb, found_level);
 
-       ret = csum_tree_block(root->fs_info, eb, 1);
+       ret = csum_tree_block(fs_info, eb, 1);
        if (ret) {
                ret = -EIO;
                goto err;
@@ -680,7 +681,7 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
 err:
        if (reads_done &&
            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) {
                /*
@@ -699,14 +700,13 @@ out:
 static int btree_io_failed_hook(struct page *page, int failed_mirror)
 {
        struct extent_buffer *eb;
-       struct btrfs_root *root = BTRFS_I(page->mapping->host)->root;
 
        eb = (struct extent_buffer *)page->private;
        set_bit(EXTENT_BUFFER_READ_ERR, &eb->bflags);
        eb->read_mirror = failed_mirror;
        atomic_dec(&eb->io_pages);
        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 */
 }
 
index 203bec4..6d9069d 100644 (file)
@@ -105,15 +105,15 @@ static int reada_add_block(struct reada_control *rc, u64 logical,
 
 /* recurses */
 /* in case of err, eb might be NULL */
-static void __readahead_hook(struct btrfs_root *root, struct reada_extent *re,
-                            struct extent_buffer *eb, u64 start, int err)
+static void __readahead_hook(struct btrfs_fs_info *fs_info,
+                            struct reada_extent *re, struct extent_buffer *eb,
+                            u64 start, int err)
 {
        int level = 0;
        int nritems;
        int i;
        u64 bytenr;
        u64 generation;
-       struct btrfs_fs_info *fs_info = root->fs_info;
        struct list_head list;
        struct btrfs_device *for_dev;
 
@@ -176,10 +176,10 @@ static void __readahead_hook(struct btrfs_root *root, struct reada_extent *re,
                         */
 #ifdef DEBUG
                        if (rec->generation != generation) {
-                               btrfs_debug(root->fs_info,
-                                          "generation mismatch for (%llu,%d,%llu) %llu != %llu",
-                                      key.objectid, key.type, key.offset,
-                                      rec->generation, generation);
+                               btrfs_debug(fs_info,
+                                           "generation mismatch for (%llu,%d,%llu) %llu != %llu",
+                                           key.objectid, key.type, key.offset,
+                                           rec->generation, generation);
                        }
 #endif
                        if (rec->generation == generation &&
@@ -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
  * failed I/O
  */
-int btree_readahead_hook(struct btrfs_root *root, struct extent_buffer *eb,
-                        u64 start, int err)
+int btree_readahead_hook(struct btrfs_fs_info *fs_info,
+                        struct extent_buffer *eb, u64 start, int err)
 {
        int ret = 0;
        struct reada_extent *re;
-       struct btrfs_fs_info *fs_info = root->fs_info;
 
        /* find extent */
        spin_lock(&fs_info->reada_lock);
@@ -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,
                        mirror_num, &eb);
        if (ret)
-               __readahead_hook(fs_info->extent_root, re, NULL, logical, ret);
+               __readahead_hook(fs_info, re, NULL, logical, ret);
        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)
                free_extent_buffer(eb);