]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/btrfs/reada.c
Merge tag 'befs-v4.10-rc1' of git://github.com/luisbg/linux-befs
[mirror_ubuntu-artful-kernel.git] / fs / btrfs / reada.c
index e910bd9b1588612a58ce0dd4eafbfc909ef44436..e88bca87f5d275c7c25b2ee6279fe4cdc1482413 100644 (file)
@@ -303,14 +303,13 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
        return zone;
 }
 
-static struct reada_extent *reada_find_extent(struct btrfs_root *root,
+static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,
                                              u64 logical,
                                              struct btrfs_key *top)
 {
        int ret;
        struct reada_extent *re = NULL;
        struct reada_extent *re_exist = NULL;
-       struct btrfs_fs_info *fs_info = root->fs_info;
        struct btrfs_bio *bbio = NULL;
        struct btrfs_device *dev;
        struct btrfs_device *prev_dev;
@@ -335,7 +334,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
        if (!re)
                return NULL;
 
-       blocksize = root->nodesize;
+       blocksize = fs_info->nodesize;
        re->logical = logical;
        re->top = *top;
        INIT_LIST_HEAD(&re->extctl);
@@ -352,7 +351,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
                goto error;
 
        if (bbio->num_stripes > BTRFS_MAX_MIRRORS) {
-               btrfs_err(root->fs_info,
+               btrfs_err(fs_info,
                           "readahead: more than %d copies not supported",
                           BTRFS_MAX_MIRRORS);
                goto error;
@@ -393,7 +392,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
        ret = radix_tree_insert(&fs_info->reada_tree, index, re);
        if (ret == -EEXIST) {
                re_exist = radix_tree_lookup(&fs_info->reada_tree, index);
-               BUG_ON(!re_exist);
                re_exist->refcnt++;
                spin_unlock(&fs_info->reada_lock);
                btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
@@ -440,7 +438,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
                                /* ignore whether the entry was inserted */
                                radix_tree_delete(&dev->reada_extents, index);
                        }
-                       BUG_ON(fs_info == NULL);
                        radix_tree_delete(&fs_info->reada_tree, index);
                        spin_unlock(&fs_info->reada_lock);
                        btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
@@ -546,17 +543,18 @@ static void reada_control_release(struct kref *kref)
 static int reada_add_block(struct reada_control *rc, u64 logical,
                           struct btrfs_key *top, u64 generation)
 {
-       struct btrfs_root *root = rc->root;
+       struct btrfs_fs_info *fs_info = rc->fs_info;
        struct reada_extent *re;
        struct reada_extctl *rec;
 
-       re = reada_find_extent(root, logical, top); /* takes one ref */
+       /* takes one ref */
+       re = reada_find_extent(fs_info, logical, top);
        if (!re)
                return -1;
 
        rec = kzalloc(sizeof(*rec), GFP_KERNEL);
        if (!rec) {
-               reada_extent_put(root->fs_info, re);
+               reada_extent_put(fs_info, re);
                return -ENOMEM;
        }
 
@@ -680,7 +678,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
                spin_unlock(&fs_info->reada_lock);
                return 0;
        }
-       dev->reada_next = re->logical + fs_info->tree_root->nodesize;
+       dev->reada_next = re->logical + fs_info->nodesize;
        re->refcnt++;
 
        spin_unlock(&fs_info->reada_lock);
@@ -706,8 +704,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
        logical = re->logical;
 
        atomic_inc(&dev->reada_in_flight);
-       ret = reada_tree_block_flagged(fs_info->extent_root, logical,
-                       mirror_num, &eb);
+       ret = reada_tree_block_flagged(fs_info, logical, mirror_num, &eb);
        if (ret)
                __readahead_hook(fs_info, re, NULL, ret);
        else if (eb)
@@ -844,7 +841,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
                        if (ret == 0)
                                break;
                        pr_debug("  re: logical %llu size %u empty %d scheduled %d",
-                               re->logical, fs_info->tree_root->nodesize,
+                               re->logical, fs_info->nodesize,
                                list_empty(&re->extctl), re->scheduled);
 
                        for (i = 0; i < re->nzones; ++i) {
@@ -877,7 +874,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
                        continue;
                }
                pr_debug("re: logical %llu size %u list empty %d scheduled %d",
-                       re->logical, fs_info->tree_root->nodesize,
+                       re->logical, fs_info->nodesize,
                        list_empty(&re->extctl), re->scheduled);
                for (i = 0; i < re->nzones; ++i) {
                        pr_cont(" zone %llu-%llu devs",
@@ -916,7 +913,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
        if (!rc)
                return ERR_PTR(-ENOMEM);
 
-       rc->root = root;
+       rc->fs_info = root->fs_info;
        rc->key_start = *key_start;
        rc->key_end = *key_end;
        atomic_set(&rc->elems, 0);
@@ -944,18 +941,17 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
 int btrfs_reada_wait(void *handle)
 {
        struct reada_control *rc = handle;
-       struct btrfs_fs_info *fs_info = rc->root->fs_info;
+       struct btrfs_fs_info *fs_info = rc->fs_info;
 
        while (atomic_read(&rc->elems)) {
                if (!atomic_read(&fs_info->reada_works_cnt))
                        reada_start_machine(fs_info);
                wait_event_timeout(rc->wait, atomic_read(&rc->elems) == 0,
                                   5 * HZ);
-               dump_devs(rc->root->fs_info,
-                         atomic_read(&rc->elems) < 10 ? 1 : 0);
+               dump_devs(fs_info, atomic_read(&rc->elems) < 10 ? 1 : 0);
        }
 
-       dump_devs(rc->root->fs_info, atomic_read(&rc->elems) < 10 ? 1 : 0);
+       dump_devs(fs_info, atomic_read(&rc->elems) < 10 ? 1 : 0);
 
        kref_put(&rc->refcnt, reada_control_release);
 
@@ -965,7 +961,7 @@ int btrfs_reada_wait(void *handle)
 int btrfs_reada_wait(void *handle)
 {
        struct reada_control *rc = handle;
-       struct btrfs_fs_info *fs_info = rc->root->fs_info;
+       struct btrfs_fs_info *fs_info = rc->fs_info;
 
        while (atomic_read(&rc->elems)) {
                if (!atomic_read(&fs_info->reada_works_cnt))