stmmac: use resource_size()
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / disk-io.c
index 009e3bd18f23d986a685c50f60e3be73a5020f31..11d0ad30e203c7ebecd9845d2989fe1c04311f60 100644 (file)
@@ -263,13 +263,15 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
 static int verify_parent_transid(struct extent_io_tree *io_tree,
                                 struct extent_buffer *eb, u64 parent_transid)
 {
+       struct extent_state *cached_state = NULL;
        int ret;
 
        if (!parent_transid || btrfs_header_generation(eb) == parent_transid)
                return 0;
 
-       lock_extent(io_tree, eb->start, eb->start + eb->len - 1, GFP_NOFS);
-       if (extent_buffer_uptodate(io_tree, eb) &&
+       lock_extent_bits(io_tree, eb->start, eb->start + eb->len - 1,
+                        0, &cached_state, GFP_NOFS);
+       if (extent_buffer_uptodate(io_tree, eb, cached_state) &&
            btrfs_header_generation(eb) == parent_transid) {
                ret = 0;
                goto out;
@@ -282,10 +284,10 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
                       (unsigned long long)btrfs_header_generation(eb));
        }
        ret = 1;
-       clear_extent_buffer_uptodate(io_tree, eb);
+       clear_extent_buffer_uptodate(io_tree, eb, &cached_state);
 out:
-       unlock_extent(io_tree, eb->start, eb->start + eb->len - 1,
-                     GFP_NOFS);
+       unlock_extent_cached(io_tree, eb->start, eb->start + eb->len - 1,
+                            &cached_state, GFP_NOFS);
        return ret;
 }
 
@@ -901,7 +903,7 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
        root->highest_objectid = 0;
        root->name = NULL;
        root->in_sysfs = 0;
-       root->inode_tree.rb_node = NULL;
+       root->inode_tree = RB_ROOT;
 
        INIT_LIST_HEAD(&root->dirty_list);
        INIT_LIST_HEAD(&root->orphan_list);
@@ -1673,7 +1675,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        insert_inode_hash(fs_info->btree_inode);
 
        spin_lock_init(&fs_info->block_group_cache_lock);
-       fs_info->block_group_cache_tree.rb_node = NULL;
+       fs_info->block_group_cache_tree = RB_ROOT;
 
        extent_io_tree_init(&fs_info->freed_extents[0],
                             fs_info->btree_inode->i_mapping, GFP_NOFS);
@@ -1982,7 +1984,12 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 
        if (!(sb->s_flags & MS_RDONLY)) {
                ret = btrfs_recover_relocation(tree_root);
-               BUG_ON(ret);
+               if (ret < 0) {
+                       printk(KERN_WARNING
+                              "btrfs: failed to recover relocation\n");
+                       err = -EINVAL;
+                       goto fail_trans_kthread;
+               }
        }
 
        location.objectid = BTRFS_FS_TREE_OBJECTID;
@@ -1993,6 +2000,12 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        if (!fs_info->fs_root)
                goto fail_trans_kthread;
 
+       if (!(sb->s_flags & MS_RDONLY)) {
+               down_read(&fs_info->cleanup_work_sem);
+               btrfs_orphan_cleanup(fs_info->fs_root);
+               up_read(&fs_info->cleanup_work_sem);
+       }
+
        return tree_root;
 
 fail_trans_kthread:
@@ -2486,7 +2499,8 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid)
        int ret;
        struct inode *btree_inode = buf->first_page->mapping->host;
 
-       ret = extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf);
+       ret = extent_buffer_uptodate(&BTRFS_I(btree_inode)->io_tree, buf,
+                                    NULL);
        if (!ret)
                return ret;