int btrfs_extent_readonly(struct btrfs_root *root, u64 bytenr);
 int btrfs_free_block_groups(struct btrfs_fs_info *info);
 int btrfs_read_block_groups(struct btrfs_fs_info *info);
-int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr);
+int btrfs_can_relocate(struct btrfs_fs_info *fs_info, u64 bytenr);
 int btrfs_make_block_group(struct btrfs_trans_handle *trans,
                           struct btrfs_root *root, u64 bytes_used,
                           u64 type, u64 chunk_objectid, u64 chunk_offset,
                                struct btrfs_fs_info *fs_info,
                                const u64 chunk_offset);
 int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
-                            struct btrfs_root *root, u64 group_start,
+                            struct btrfs_fs_info *fs_info, u64 group_start,
                             struct extent_map *em);
 void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info);
 void btrfs_get_block_group_trimming(struct btrfs_block_group_cache *cache);
 
 /* root-item.c */
 int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
-                      struct btrfs_root *tree_root,
+                      struct btrfs_fs_info *fs_info,
                       u64 root_id, u64 ref_id, u64 dirid, u64 sequence,
                       const char *name, int name_len);
 int btrfs_del_root_ref(struct btrfs_trans_handle *trans,
-                      struct btrfs_root *tree_root,
+                      struct btrfs_fs_info *fs_info,
                       u64 root_id, u64 ref_id, u64 dirid, u64 *sequence,
                       const char *name, int name_len);
 int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 int btrfs_find_root(struct btrfs_root *root, struct btrfs_key *search_key,
                    struct btrfs_path *path, struct btrfs_root_item *root_item,
                    struct btrfs_key *root_key);
-int btrfs_find_orphan_roots(struct btrfs_root *tree_root);
+int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info);
 void btrfs_set_root_node(struct btrfs_root_item *item,
                         struct extent_buffer *node);
 void btrfs_check_and_init_root_item(struct btrfs_root_item *item);
 
 /* uuid-tree.c */
 int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans,
-                       struct btrfs_root *uuid_root, u8 *uuid, u8 type,
+                       struct btrfs_fs_info *fs_info, u8 *uuid, u8 type,
                        u64 subid);
 int btrfs_uuid_tree_rem(struct btrfs_trans_handle *trans,
-                       struct btrfs_root *uuid_root, u8 *uuid, u8 type,
+                       struct btrfs_fs_info *fs_info, u8 *uuid, u8 type,
                        u64 subid);
 int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info,
                            int (*check_func)(struct btrfs_fs_info *, u8 *, u8,
 #endif
 
 /* relocation.c */
-int btrfs_relocate_block_group(struct btrfs_root *root, u64 group_start);
+int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start);
 int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,
                          struct btrfs_root *root);
 int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
 
        init_waitqueue_head(&fs_info->balance_wait_q);
 }
 
-static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info,
-                                  struct btrfs_root *tree_root)
+static void btrfs_init_btree_inode(struct btrfs_fs_info *fs_info)
 {
        fs_info->btree_inode->i_ino = BTRFS_BTREE_INODE_OBJECTID;
        set_nlink(fs_info->btree_inode, 1);
 
        BTRFS_I(fs_info->btree_inode)->io_tree.ops = &btree_extent_io_ops;
 
-       BTRFS_I(fs_info->btree_inode)->root = tree_root;
+       BTRFS_I(fs_info->btree_inode)->root = fs_info->tree_root;
        memset(&BTRFS_I(fs_info->btree_inode)->location, 0,
               sizeof(struct btrfs_key));
        set_bit(BTRFS_INODE_DUMMY,
        }
 
        if (fs_info->sb->s_flags & MS_RDONLY) {
-               ret = btrfs_commit_super(tree_root);
+               ret = btrfs_commit_super(fs_info);
                if (ret)
                        return ret;
        }
        return 0;
 }
 
-static int btrfs_read_roots(struct btrfs_fs_info *fs_info,
-                           struct btrfs_root *tree_root)
+static int btrfs_read_roots(struct btrfs_fs_info *fs_info)
 {
+       struct btrfs_root *tree_root = fs_info->tree_root;
        struct btrfs_root *root;
        struct btrfs_key location;
        int ret;
 
+       BUG_ON(!fs_info->tree_root);
+
        location.objectid = BTRFS_EXTENT_TREE_OBJECTID;
        location.type = BTRFS_ROOT_ITEM_KEY;
        location.offset = 0;
        sb->s_blocksize_bits = blksize_bits(4096);
        sb->s_bdi = &fs_info->bdi;
 
-       btrfs_init_btree_inode(fs_info, tree_root);
+       btrfs_init_btree_inode(fs_info);
 
        spin_lock_init(&fs_info->block_group_cache_lock);
        fs_info->block_group_cache_tree = RB_ROOT;
        sb->s_blocksize_bits = blksize_bits(sectorsize);
 
        mutex_lock(&fs_info->chunk_mutex);
-       ret = btrfs_read_sys_array(tree_root);
+       ret = btrfs_read_sys_array(fs_info);
        mutex_unlock(&fs_info->chunk_mutex);
        if (ret) {
                btrfs_err(fs_info, "failed to read the system array: %d", ret);
 
        mutex_unlock(&tree_root->objectid_mutex);
 
-       ret = btrfs_read_roots(fs_info, tree_root);
+       ret = btrfs_read_roots(fs_info);
        if (ret)
                goto recovery_tree_root;
 
                }
        }
 
-       ret = btrfs_find_orphan_roots(tree_root);
+       ret = btrfs_find_orphan_roots(fs_info);
        if (ret)
                goto fail_qgroup;
 
                if (ret) {
                        btrfs_warn(fs_info,
                                   "failed to clear free space tree: %d", ret);
-                       close_ctree(tree_root);
+                       close_ctree(fs_info);
                        return ret;
                }
        }
                if (ret) {
                        btrfs_warn(fs_info,
                                "failed to create free space tree: %d", ret);
-                       close_ctree(tree_root);
+                       close_ctree(fs_info);
                        return ret;
                }
        }
        if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) ||
            (ret = btrfs_orphan_cleanup(fs_info->tree_root))) {
                up_read(&fs_info->cleanup_work_sem);
-               close_ctree(tree_root);
+               close_ctree(fs_info);
                return ret;
        }
        up_read(&fs_info->cleanup_work_sem);
        ret = btrfs_resume_balance_async(fs_info);
        if (ret) {
                btrfs_warn(fs_info, "failed to resume balance: %d", ret);
-               close_ctree(tree_root);
+               close_ctree(fs_info);
                return ret;
        }
 
        ret = btrfs_resume_dev_replace_async(fs_info);
        if (ret) {
                btrfs_warn(fs_info, "failed to resume device replace: %d", ret);
-               close_ctree(tree_root);
+               close_ctree(fs_info);
                return ret;
        }
 
                if (ret) {
                        btrfs_warn(fs_info,
                                "failed to create the UUID tree: %d", ret);
-                       close_ctree(tree_root);
+                       close_ctree(fs_info);
                        return ret;
                }
        } else if (btrfs_test_opt(tree_root->fs_info, RESCAN_UUID_TREE) ||
                if (ret) {
                        btrfs_warn(fs_info,
                                "failed to check the UUID tree: %d", ret);
-                       close_ctree(tree_root);
+                       close_ctree(fs_info);
                        return ret;
                }
        } else {
        return err;
 }
 
-int btrfs_commit_super(struct btrfs_root *root)
+int btrfs_commit_super(struct btrfs_fs_info *fs_info)
 {
+       struct btrfs_root *root = fs_info->tree_root;
        struct btrfs_trans_handle *trans;
 
        mutex_lock(&root->fs_info->cleaner_mutex);
        return btrfs_commit_transaction(trans, root);
 }
 
-void close_ctree(struct btrfs_root *root)
+void close_ctree(struct btrfs_fs_info *fs_info)
 {
-       struct btrfs_fs_info *fs_info = root->fs_info;
+       struct btrfs_root *root = fs_info->tree_root;
        int ret;
 
        set_bit(BTRFS_FS_CLOSING_START, &fs_info->flags);
                 */
                btrfs_delete_unused_bgs(root->fs_info);
 
-               ret = btrfs_commit_super(root);
+               ret = btrfs_commit_super(fs_info);
                if (ret)
                        btrfs_err(fs_info, "commit super ret %d", ret);
        }
 
 int open_ctree(struct super_block *sb,
               struct btrfs_fs_devices *fs_devices,
               char *options);
-void close_ctree(struct btrfs_root *root);
+void close_ctree(struct btrfs_fs_info *fs_info);
 int write_ctree_super(struct btrfs_trans_handle *trans,
                      struct btrfs_root *root, int max_mirrors);
 struct buffer_head *btrfs_read_dev_super(struct block_device *bdev);
 int btrfs_read_dev_one_super(struct block_device *bdev, int copy_num,
                        struct buffer_head **bh_ret);
-int btrfs_commit_super(struct btrfs_root *root);
+int btrfs_commit_super(struct btrfs_fs_info *fs_info);
 struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root,
                                      struct btrfs_key *location);
 int btrfs_init_fs_root(struct btrfs_root *root);
 
  * @return - -1 if it's not a good idea to relocate this block group, 0 if its
  * ok to go ahead and try.
  */
-int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
+int btrfs_can_relocate(struct btrfs_fs_info *fs_info, u64 bytenr)
 {
+       struct btrfs_root *root = fs_info->extent_root;
        struct btrfs_block_group_cache *block_group;
        struct btrfs_space_info *space_info;
        struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
        return ret;
 }
 
-static int find_first_block_group(struct btrfs_root *root,
-               struct btrfs_path *path, struct btrfs_key *key)
+static int find_first_block_group(struct btrfs_fs_info *fs_info,
+                                 struct btrfs_path *path,
+                                 struct btrfs_key *key)
 {
+       struct btrfs_root *root = fs_info->extent_root;
        int ret = 0;
        struct btrfs_key found_key;
        struct extent_buffer *leaf;
                need_clear = 1;
 
        while (1) {
-               ret = find_first_block_group(root, path, &key);
+               ret = find_first_block_group(info, path, &key);
                if (ret > 0)
                        break;
                if (ret != 0)
                                        sizeof(item));
                if (ret)
                        btrfs_abort_transaction(trans, ret);
-               ret = btrfs_finish_chunk_alloc(trans, extent_root,
+               ret = btrfs_finish_chunk_alloc(trans, extent_root->fs_info,
                                               key.objectid, key.offset);
                if (ret)
                        btrfs_abort_transaction(trans, ret);
 }
 
 int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
-                            struct btrfs_root *root, u64 group_start,
+                            struct btrfs_fs_info *fs_info, u64 group_start,
                             struct extent_map *em)
 {
+       struct btrfs_root *root = fs_info->extent_root;
        struct btrfs_path *path;
        struct btrfs_block_group_cache *block_group;
        struct btrfs_free_cluster *cluster;
        struct btrfs_caching_control *caching_ctl = NULL;
        bool remove_em;
 
-       root = root->fs_info->extent_root;
-
-       block_group = btrfs_lookup_block_group(root->fs_info, group_start);
+       block_group = btrfs_lookup_block_group(fs_info, group_start);
        BUG_ON(!block_group);
        BUG_ON(!block_group->ro);
 
 
        }
        btrfs_release_path(path);
 
-       ret = btrfs_del_root_ref(trans, root->fs_info->tree_root,
+       ret = btrfs_del_root_ref(trans, root->fs_info,
                                 objectid, root->root_key.objectid,
                                 dir_ino, &index, name, name_len);
        if (ret < 0) {
        }
 
        if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
-               ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
+               ret = btrfs_add_root_ref(trans, root->fs_info,
                                         key.objectid, root->root_key.objectid,
                                         parent_ino, index, name, name_len);
        } else if (add_backref) {
        if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
                u64 local_index;
                int err;
-               err = btrfs_del_root_ref(trans, root->fs_info->tree_root,
+               err = btrfs_del_root_ref(trans, root->fs_info,
                                 key.objectid, root->root_key.objectid,
                                 parent_ino, &local_index, name, name_len);
 
 
        ret = btrfs_update_inode(trans, root, dir);
        BUG_ON(ret);
 
-       ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
+       ret = btrfs_add_root_ref(trans, root->fs_info,
                                 objectid, root->root_key.objectid,
                                 btrfs_ino(dir), index, name, namelen);
        BUG_ON(ret);
 
-       ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root,
-                                 root_item->uuid, BTRFS_UUID_KEY_SUBVOL,
-                                 objectid);
+       ret = btrfs_uuid_tree_add(trans, root->fs_info, root_item->uuid,
+                                 BTRFS_UUID_KEY_SUBVOL, objectid);
        if (ret)
                btrfs_abort_transaction(trans, ret);
 
                }
        }
 
-       ret = btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root,
-                                 dest->root_item.uuid, BTRFS_UUID_KEY_SUBVOL,
+       ret = btrfs_uuid_tree_rem(trans, root->fs_info, dest->root_item.uuid,
+                                 BTRFS_UUID_KEY_SUBVOL,
                                  dest->root_key.objectid);
        if (ret && ret != -ENOENT) {
                btrfs_abort_transaction(trans, ret);
                goto out_end_trans;
        }
        if (!btrfs_is_empty_uuid(dest->root_item.received_uuid)) {
-               ret = btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root,
+               ret = btrfs_uuid_tree_rem(trans, root->fs_info,
                                          dest->root_item.received_uuid,
                                          BTRFS_UUID_KEY_RECEIVED_SUBVOL,
                                          dest->root_key.objectid);
                                       BTRFS_UUID_SIZE);
        if (received_uuid_changed &&
            !btrfs_is_empty_uuid(root_item->received_uuid))
-               btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root,
+               btrfs_uuid_tree_rem(trans, root->fs_info,
                                    root_item->received_uuid,
                                    BTRFS_UUID_KEY_RECEIVED_SUBVOL,
                                    root->root_key.objectid);
                goto out;
        }
        if (received_uuid_changed && !btrfs_is_empty_uuid(sa->uuid)) {
-               ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root,
-                                         sa->uuid,
+               ret = btrfs_uuid_tree_add(trans, root->fs_info, sa->uuid,
                                          BTRFS_UUID_KEY_RECEIVED_SUBVOL,
                                          root->root_key.objectid);
                if (ret < 0 && ret != -EEXIST) {
 
 /*
  * function to relocate all extents in a block group.
  */
-int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
+int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
 {
-       struct btrfs_fs_info *fs_info = extent_root->fs_info;
+       struct btrfs_root *extent_root = fs_info->extent_root;
        struct reloc_control *rc;
        struct inode *inode;
        struct btrfs_path *path;
 
        return btrfs_insert_item(trans, root, key, item, sizeof(*item));
 }
 
-int btrfs_find_orphan_roots(struct btrfs_root *tree_root)
+int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info)
 {
+       struct btrfs_root *tree_root = fs_info->tree_root;
        struct extent_buffer *leaf;
        struct btrfs_path *path;
        struct btrfs_key key;
 }
 
 int btrfs_del_root_ref(struct btrfs_trans_handle *trans,
-                      struct btrfs_root *tree_root,
+                      struct btrfs_fs_info *fs_info,
                       u64 root_id, u64 ref_id, u64 dirid, u64 *sequence,
                       const char *name, int name_len)
 
 {
+       struct btrfs_root *tree_root = fs_info->tree_root;
        struct btrfs_path *path;
        struct btrfs_root_ref *ref;
        struct extent_buffer *leaf;
  * Will return 0, -ENOMEM, or anything from the CoW path
  */
 int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
-                      struct btrfs_root *tree_root,
+                      struct btrfs_fs_info *fs_info,
                       u64 root_id, u64 ref_id, u64 dirid, u64 sequence,
                       const char *name, int name_len)
 {
+       struct btrfs_root *tree_root = fs_info->tree_root;
        struct btrfs_key key;
        int ret;
        struct btrfs_path *path;
 
 
 static void btrfs_put_super(struct super_block *sb)
 {
-       close_ctree(btrfs_sb(sb)->tree_root);
+       close_ctree(btrfs_sb(sb));
 }
 
 enum {
        return 0;
 
 fail_close:
-       close_ctree(fs_info->tree_root);
+       close_ctree(fs_info);
        return err;
 }
 
                btrfs_scrub_cancel(fs_info);
                btrfs_pause_balance(fs_info);
 
-               ret = btrfs_commit_super(root);
+               ret = btrfs_commit_super(fs_info);
                if (ret)
                        goto restore;
        } else {
  * The helper to calc the free space on the devices that can be used to store
  * file data.
  */
-static int btrfs_calc_avail_data_space(struct btrfs_root *root, u64 *free_bytes)
+static int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
+                                      u64 *free_bytes)
 {
-       struct btrfs_fs_info *fs_info = root->fs_info;
+       struct btrfs_root *root = fs_info->tree_root;
        struct btrfs_device_info *devices_info;
        struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
        struct btrfs_device *device;
        spin_unlock(&block_rsv->lock);
 
        buf->f_bavail = div_u64(total_free_data, factor);
-       ret = btrfs_calc_avail_data_space(fs_info->tree_root, &total_free_data);
+       ret = btrfs_calc_avail_data_space(fs_info, &total_free_data);
        if (ret)
                return ret;
        buf->f_bavail += div_u64(total_free_data, factor);
 
        /*
         * insert root back/forward references
         */
-       ret = btrfs_add_root_ref(trans, tree_root, objectid,
+       ret = btrfs_add_root_ref(trans, fs_info, objectid,
                                 parent_root->root_key.objectid,
                                 btrfs_ino(parent_inode), index,
                                 dentry->d_name.name, dentry->d_name.len);
                btrfs_abort_transaction(trans, ret);
                goto fail;
        }
-       ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, new_uuid.b,
+       ret = btrfs_uuid_tree_add(trans, fs_info, new_uuid.b,
                                  BTRFS_UUID_KEY_SUBVOL, objectid);
        if (ret) {
                btrfs_abort_transaction(trans, ret);
                goto fail;
        }
        if (!btrfs_is_empty_uuid(new_root_item->received_uuid)) {
-               ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root,
+               ret = btrfs_uuid_tree_add(trans, fs_info,
                                          new_root_item->received_uuid,
                                          BTRFS_UUID_KEY_RECEIVED_SUBVOL,
                                          objectid);
 
 }
 
 int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans,
-                       struct btrfs_root *uuid_root, u8 *uuid, u8 type,
+                       struct btrfs_fs_info *fs_info, u8 *uuid, u8 type,
                        u64 subid_cpu)
 {
+       struct btrfs_root *uuid_root = fs_info->uuid_root;
        int ret;
        struct btrfs_path *path = NULL;
        struct btrfs_key key;
                offset = btrfs_item_ptr_offset(eb, slot);
                offset += btrfs_item_size_nr(eb, slot) - sizeof(subid_le);
        } else if (ret < 0) {
-               btrfs_warn(uuid_root->fs_info,
+               btrfs_warn(fs_info,
                           "insert uuid item failed %d (0x%016llx, 0x%016llx) type %u!",
                           ret, (unsigned long long)key.objectid,
                           (unsigned long long)key.offset, type);
 }
 
 int btrfs_uuid_tree_rem(struct btrfs_trans_handle *trans,
-                       struct btrfs_root *uuid_root, u8 *uuid, u8 type,
+                       struct btrfs_fs_info *fs_info, u8 *uuid, u8 type,
                        u64 subid)
 {
+       struct btrfs_root *uuid_root = fs_info->uuid_root;
        int ret;
        struct btrfs_path *path = NULL;
        struct btrfs_key key;
                goto out;
        }
 
-       ret = btrfs_uuid_tree_rem(trans, uuid_root, uuid, type, subid);
+       ret = btrfs_uuid_tree_rem(trans, uuid_root->fs_info, uuid, type, subid);
        btrfs_end_transaction(trans, uuid_root);
 
 out:
 
        return ret;
 }
 
-static int btrfs_del_sys_chunk(struct btrfs_root *root, u64 chunk_objectid, u64
-                       chunk_offset)
+static int btrfs_del_sys_chunk(struct btrfs_fs_info *fs_info,
+                              u64 chunk_objectid, u64 chunk_offset)
 {
+       struct btrfs_root *root = fs_info->chunk_root;
        struct btrfs_super_block *super_copy = root->fs_info->super_copy;
        struct btrfs_disk_key *disk_key;
        struct btrfs_chunk *chunk;
                goto out;
        }
 
-       trace_btrfs_chunk_free(root, map, chunk_offset, em->len);
+       trace_btrfs_chunk_free(fs_info, map, chunk_offset, em->len);
 
        if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) {
-               ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset);
+               ret = btrfs_del_sys_chunk(fs_info, chunk_objectid,
+                                         chunk_offset);
                if (ret) {
                        btrfs_abort_transaction(trans, ret);
                        goto out;
                }
        }
 
-       ret = btrfs_remove_block_group(trans, extent_root, chunk_offset, em);
+       ret = btrfs_remove_block_group(trans, fs_info, chunk_offset, em);
        if (ret) {
                btrfs_abort_transaction(trans, ret);
                goto out;
         */
        ASSERT(mutex_is_locked(&root->fs_info->delete_unused_bgs_mutex));
 
-       ret = btrfs_can_relocate(extent_root, chunk_offset);
+       ret = btrfs_can_relocate(root->fs_info, chunk_offset);
        if (ret)
                return -ENOSPC;
 
        /* step one, relocate all the extents inside this chunk */
        btrfs_scrub_pause(root);
-       ret = btrfs_relocate_block_group(extent_root, chunk_offset);
+       ret = btrfs_relocate_block_group(root->fs_info, chunk_offset);
        btrfs_scrub_continue(root);
        if (ret)
                return ret;
        return ret;
 }
 
-static int insert_balance_item(struct btrfs_root *root,
+static int insert_balance_item(struct btrfs_fs_info *fs_info,
                               struct btrfs_balance_control *bctl)
 {
+       struct btrfs_root *root = fs_info->tree_root;
        struct btrfs_trans_handle *trans;
        struct btrfs_balance_item *item;
        struct btrfs_disk_balance_args disk_bargs;
        return ret;
 }
 
-static int del_balance_item(struct btrfs_root *root)
+static int del_balance_item(struct btrfs_fs_info *fs_info)
 {
+       struct btrfs_root *root = fs_info->tree_root;
        struct btrfs_trans_handle *trans;
        struct btrfs_path *path;
        struct btrfs_key key;
        int ret;
 
        unset_balance_control(fs_info);
-       ret = del_balance_item(fs_info->tree_root);
+       ret = del_balance_item(fs_info);
        if (ret)
                btrfs_handle_fs_error(fs_info, ret, NULL);
 
                                bctl->sys.target));
        }
 
-       ret = insert_balance_item(fs_info->tree_root, bctl);
+       ret = insert_balance_item(fs_info, bctl);
        if (ret && ret != -EEXIST)
                goto out;
 
                }
 update_tree:
                if (!btrfs_is_empty_uuid(root_item.uuid)) {
-                       ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root,
+                       ret = btrfs_uuid_tree_add(trans, fs_info,
                                                  root_item.uuid,
                                                  BTRFS_UUID_KEY_SUBVOL,
                                                  key.objectid);
                }
 
                if (!btrfs_is_empty_uuid(root_item.received_uuid)) {
-                       ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root,
+                       ret = btrfs_uuid_tree_add(trans, fs_info,
                                                  root_item.received_uuid,
                                                 BTRFS_UUID_KEY_RECEIVED_SUBVOL,
                                                  key.objectid);
 
        num_bytes = stripe_size * data_stripes;
 
-       trace_btrfs_chunk_alloc(info->chunk_root, map, start, num_bytes);
+       trace_btrfs_chunk_alloc(info, map, start, num_bytes);
 
        em = alloc_extent_map();
        if (!em) {
 }
 
 int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
-                               struct btrfs_root *extent_root,
+                               struct btrfs_fs_info *fs_info,
                                u64 chunk_offset, u64 chunk_size)
 {
+       struct btrfs_root *extent_root = fs_info->extent_root;
+       struct btrfs_root *chunk_root = fs_info->chunk_root;
        struct btrfs_key key;
-       struct btrfs_root *chunk_root = extent_root->fs_info->chunk_root;
        struct btrfs_device *device;
        struct btrfs_chunk *chunk;
        struct btrfs_stripe *stripe;
        return ret;
 }
 
-int btrfs_read_sys_array(struct btrfs_root *root)
+int btrfs_read_sys_array(struct btrfs_fs_info *fs_info)
 {
-       struct btrfs_fs_info *fs_info = root->fs_info;
+       struct btrfs_root *root = fs_info->tree_root;
        struct btrfs_super_block *super_copy = fs_info->super_copy;
        struct extent_buffer *sb;
        struct btrfs_disk_key *disk_key;
 }
 
 static int update_dev_stat_item(struct btrfs_trans_handle *trans,
-                               struct btrfs_root *dev_root,
+                               struct btrfs_fs_info *fs_info,
                                struct btrfs_device *device)
 {
+       struct btrfs_root *dev_root = fs_info->dev_root;
        struct btrfs_path *path;
        struct btrfs_key key;
        struct extent_buffer *eb;
 int btrfs_run_dev_stats(struct btrfs_trans_handle *trans,
                        struct btrfs_fs_info *fs_info)
 {
-       struct btrfs_root *dev_root = fs_info->dev_root;
        struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
        struct btrfs_device *device;
        int stats_cnt;
                        continue;
 
                stats_cnt = atomic_read(&device->dev_stats_ccnt);
-               ret = update_dev_stat_item(trans, dev_root, device);
+               ret = update_dev_stat_item(trans, fs_info, device);
                if (!ret)
                        atomic_sub(stats_cnt, &device->dev_stats_ccnt);
        }
 
 int btrfs_rmap_block(struct btrfs_fs_info *fs_info,
                     u64 chunk_start, u64 physical, u64 devid,
                     u64 **logical, int *naddrs, int *stripe_len);
-int btrfs_read_sys_array(struct btrfs_root *root);
+int btrfs_read_sys_array(struct btrfs_fs_info *fs_info);
 int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info);
 int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
                      struct btrfs_root *extent_root, u64 type);
                                    struct btrfs_mapping_tree *map_tree,
                                    u64 logical);
 int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
-                               struct btrfs_root *extent_root,
+                               struct btrfs_fs_info *fs_info,
                                u64 chunk_offset, u64 chunk_size);
 int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
                       struct btrfs_fs_info *fs_info, u64 chunk_offset);
 
 
 DECLARE_EVENT_CLASS(btrfs__chunk,
 
-       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+       TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
                 u64 offset, u64 size),
 
-       TP_ARGS(root, map, offset, size),
+       TP_ARGS(fs_info, map, offset, size),
 
        TP_STRUCT__entry_btrfs(
                __field(        int,  num_stripes               )
                __field(        u64,  root_objectid             )
        ),
 
-       TP_fast_assign_btrfs(root->fs_info,
+       TP_fast_assign_btrfs(fs_info,
                __entry->num_stripes    = map->num_stripes;
                __entry->type           = map->type;
                __entry->sub_stripes    = map->sub_stripes;
                __entry->offset         = offset;
                __entry->size           = size;
-               __entry->root_objectid  = root->root_key.objectid;
+               __entry->root_objectid  = fs_info->chunk_root->root_key.objectid;
        ),
 
        TP_printk_btrfs("root = %llu(%s), offset = %llu, size = %llu, "
 
 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
 
-       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+       TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
                 u64 offset, u64 size),
 
-       TP_ARGS(root, map, offset, size)
+       TP_ARGS(fs_info, map, offset, size)
 );
 
 DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
 
-       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+       TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map,
                 u64 offset, u64 size),
 
-       TP_ARGS(root, map, offset, size)
+       TP_ARGS(fs_info, map, offset, size)
 );
 
 TRACE_EVENT(btrfs_cow_block,