Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs...
[sfrench/cifs-2.6.git] / fs / btrfs / disk-io.c
index 8ecc5419d8b6c3d64ccac45d5ae5c279a24457ee..8f1d44ba332f487aa42e3291daa63e45b04d44e0 100644 (file)
@@ -936,7 +936,6 @@ static const struct address_space_operations btree_aops = {
        .writepages     = btree_writepages,
        .releasepage    = btree_releasepage,
        .invalidatepage = btree_invalidatepage,
-       .sync_page      = block_sync_page,
 #ifdef CONFIG_MIGRATION
        .migratepage    = btree_migratepage,
 #endif
@@ -1276,8 +1275,10 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root,
        root->commit_root = btrfs_root_node(root);
        BUG_ON(!root->node);
 out:
-       if (location->objectid != BTRFS_TREE_LOG_OBJECTID)
+       if (location->objectid != BTRFS_TREE_LOG_OBJECTID) {
                root->ref_cows = 1;
+               btrfs_check_and_init_root_item(&root->root_item);
+       }
 
        return root;
 }
@@ -1422,82 +1423,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
        return ret;
 }
 
-/*
- * this unplugs every device on the box, and it is only used when page
- * is null
- */
-static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
-{
-       struct btrfs_device *device;
-       struct btrfs_fs_info *info;
-
-       info = (struct btrfs_fs_info *)bdi->unplug_io_data;
-       list_for_each_entry(device, &info->fs_devices->devices, dev_list) {
-               if (!device->bdev)
-                       continue;
-
-               bdi = blk_get_backing_dev_info(device->bdev);
-               if (bdi->unplug_io_fn)
-                       bdi->unplug_io_fn(bdi, page);
-       }
-}
-
-static void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
-{
-       struct inode *inode;
-       struct extent_map_tree *em_tree;
-       struct extent_map *em;
-       struct address_space *mapping;
-       u64 offset;
-
-       /* the generic O_DIRECT read code does this */
-       if (1 || !page) {
-               __unplug_io_fn(bdi, page);
-               return;
-       }
-
-       /*
-        * page->mapping may change at any time.  Get a consistent copy
-        * and use that for everything below
-        */
-       smp_mb();
-       mapping = page->mapping;
-       if (!mapping)
-               return;
-
-       inode = mapping->host;
-
-       /*
-        * don't do the expensive searching for a small number of
-        * devices
-        */
-       if (BTRFS_I(inode)->root->fs_info->fs_devices->open_devices <= 2) {
-               __unplug_io_fn(bdi, page);
-               return;
-       }
-
-       offset = page_offset(page);
-
-       em_tree = &BTRFS_I(inode)->extent_tree;
-       read_lock(&em_tree->lock);
-       em = lookup_extent_mapping(em_tree, offset, PAGE_CACHE_SIZE);
-       read_unlock(&em_tree->lock);
-       if (!em) {
-               __unplug_io_fn(bdi, page);
-               return;
-       }
-
-       if (em->block_start >= EXTENT_MAP_LAST_BYTE) {
-               free_extent_map(em);
-               __unplug_io_fn(bdi, page);
-               return;
-       }
-       offset = offset - em->start;
-       btrfs_unplug_page(&BTRFS_I(inode)->root->fs_info->mapping_tree,
-                         em->block_start + offset, page);
-       free_extent_map(em);
-}
-
 /*
  * If this fails, caller must call bdi_destroy() to get rid of the
  * bdi again.
@@ -1512,8 +1437,6 @@ static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
                return err;
 
        bdi->ra_pages   = default_backing_dev_info.ra_pages;
-       bdi->unplug_io_fn       = btrfs_unplug_io_fn;
-       bdi->unplug_io_data     = info;
        bdi->congested_fn       = btrfs_congested_fn;
        bdi->congested_data     = info;
        return 0;
@@ -1724,6 +1647,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
                goto fail_bdi;
        }
 
+       fs_info->btree_inode->i_mapping->flags &= ~__GFP_FS;
+
        INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC);
        INIT_LIST_HEAD(&fs_info->trans_list);
        INIT_LIST_HEAD(&fs_info->dead_roots);
@@ -2065,6 +1990,12 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        fs_info->metadata_alloc_profile = (u64)-1;
        fs_info->system_alloc_profile = fs_info->metadata_alloc_profile;
 
+       ret = btrfs_init_space_info(fs_info);
+       if (ret) {
+               printk(KERN_ERR "Failed to initial space info: %d\n", ret);
+               goto fail_block_groups;
+       }
+
        ret = btrfs_read_block_groups(extent_root);
        if (ret) {
                printk(KERN_ERR "Failed to read block groups: %d\n", ret);
@@ -2600,7 +2531,7 @@ int close_ctree(struct btrfs_root *root)
         * ERROR state on disk.
         *
         * 2. when btrfs flips readonly just in btrfs_commit_super,
-        * and in such case, btrfs cannnot write sb via btrfs_commit_super,
+        * and in such case, btrfs cannot write sb via btrfs_commit_super,
         * and since fs_state has been set BTRFS_SUPER_FLAG_ERROR flag,
         * btrfs will cleanup all FS resources first and write sb then.
         */