Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 26 Apr 2011 15:26:58 +0000 (08:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 26 Apr 2011 15:26:58 +0000 (08:26 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable:
  Btrfs: cleanup error handling in inode.c
  Btrfs: put the right bio if we have an error
  Btrfs: free bitmaps properly when evicting the cache
  Btrfs: Free free_space item properly in btrfs_trim_block_group()
  btrfs: add missing spin_unlock to a rare exit path
  Btrfs: check return value of kmalloc()
  btrfs: fix wrong allocating flag when reading page
  Btrfs: fix missing mutex_unlock in btrfs_del_dir_entries_in_log()

1  2 
fs/btrfs/disk-io.c
fs/btrfs/extent_io.c
fs/btrfs/inode.c

diff --combined fs/btrfs/disk-io.c
@@@ -936,6 -936,7 +936,6 @@@ static const struct address_space_opera
        .writepages     = btree_writepages,
        .releasepage    = btree_releasepage,
        .invalidatepage = btree_invalidatepage,
 -      .sync_page      = block_sync_page,
  #ifdef CONFIG_MIGRATION
        .migratepage    = btree_migratepage,
  #endif
@@@ -1423,6 -1424,82 +1423,6 @@@ static int btrfs_congested_fn(void *con
        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.
@@@ -1437,6 -1514,8 +1437,6 @@@ static int setup_bdi(struct btrfs_fs_in
                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;
@@@ -2531,7 -2610,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.
         */
@@@ -2824,6 -2903,7 +2824,7 @@@ static int btrfs_destroy_delayed_refs(s
  
        spin_lock(&delayed_refs->lock);
        if (delayed_refs->num_entries == 0) {
+               spin_unlock(&delayed_refs->lock);
                printk(KERN_INFO "delayed_refs has NO entry\n");
                return ret;
        }
diff --combined fs/btrfs/extent_io.c
@@@ -2219,7 -2219,7 +2219,7 @@@ static int __extent_writepage(struct pa
        unsigned long nr_written = 0;
  
        if (wbc->sync_mode == WB_SYNC_ALL)
 -              write_flags = WRITE_SYNC_PLUG;
 +              write_flags = WRITE_SYNC;
        else
                write_flags = WRITE;
  
@@@ -2681,7 -2681,7 +2681,7 @@@ int extent_readpages(struct extent_io_t
                prefetchw(&page->flags);
                list_del(&page->lru);
                if (!add_to_page_cache_lru(page, mapping,
-                                       page->index, GFP_KERNEL)) {
+                                       page->index, GFP_NOFS)) {
                        __extent_read_full_page(tree, page, get_extent,
                                                &bio, 0, &bio_flags);
                }
diff --combined fs/btrfs/inode.c
@@@ -93,14 -93,13 +93,14 @@@ static noinline int cow_file_range(stru
                                   unsigned long *nr_written, int unlock);
  
  static int btrfs_init_inode_security(struct btrfs_trans_handle *trans,
 -                                   struct inode *inode,  struct inode *dir)
 +                                   struct inode *inode,  struct inode *dir,
 +                                   const struct qstr *qstr)
  {
        int err;
  
        err = btrfs_init_acl(trans, inode, dir);
        if (!err)
 -              err = btrfs_xattr_security_init(trans, inode, dir);
 +              err = btrfs_xattr_security_init(trans, inode, dir, qstr);
        return err;
  }
  
@@@ -954,6 -953,7 +954,7 @@@ static int cow_file_range_async(struct 
                         1, 0, NULL, GFP_NOFS);
        while (start < end) {
                async_cow = kmalloc(sizeof(*async_cow), GFP_NOFS);
+               BUG_ON(!async_cow);
                async_cow->inode = inode;
                async_cow->root = root;
                async_cow->locked_page = locked_page;
@@@ -2324,7 -2324,7 +2325,7 @@@ int btrfs_orphan_cleanup(struct btrfs_r
  
                /*
                 * if ret == 0 means we found what we were searching for, which
 -               * is weird, but possible, so only screw with path if we didnt
 +               * is weird, but possible, so only screw with path if we didn't
                 * find the key and see if we have stuff that matches
                 */
                if (ret > 0) {
@@@ -4731,11 -4731,12 +4732,12 @@@ static int btrfs_mknod(struct inode *di
        inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
                                dentry->d_name.len, dir->i_ino, objectid,
                                BTRFS_I(dir)->block_group, mode, &index);
-       err = PTR_ERR(inode);
-       if (IS_ERR(inode))
+       if (IS_ERR(inode)) {
+               err = PTR_ERR(inode);
                goto out_unlock;
+       }
  
 -      err = btrfs_init_inode_security(trans, inode, dir);
 +      err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
        if (err) {
                drop_inode = 1;
                goto out_unlock;
@@@ -4792,11 -4793,12 +4794,12 @@@ static int btrfs_create(struct inode *d
        inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
                                dentry->d_name.len, dir->i_ino, objectid,
                                BTRFS_I(dir)->block_group, mode, &index);
-       err = PTR_ERR(inode);
-       if (IS_ERR(inode))
+       if (IS_ERR(inode)) {
+               err = PTR_ERR(inode);
                goto out_unlock;
+       }
  
 -      err = btrfs_init_inode_security(trans, inode, dir);
 +      err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
        if (err) {
                drop_inode = 1;
                goto out_unlock;
@@@ -4837,6 -4839,9 +4840,6 @@@ static int btrfs_link(struct dentry *ol
        int err;
        int drop_inode = 0;
  
 -      if (inode->i_nlink == 0)
 -              return -ENOENT;
 -
        /* do not allow sys_link's with other subvols of the same device */
        if (root->objectid != BTRFS_I(inode)->root->objectid)
                return -EXDEV;
@@@ -4925,7 -4930,7 +4928,7 @@@ static int btrfs_mkdir(struct inode *di
  
        drop_on_err = 1;
  
 -      err = btrfs_init_inode_security(trans, inode, dir);
 +      err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
        if (err)
                goto out_fail;
  
@@@ -4999,6 -5004,8 +5002,8 @@@ static noinline int uncompress_inline(s
        inline_size = btrfs_file_extent_inline_item_len(leaf,
                                        btrfs_item_nr(leaf, path->slots[0]));
        tmp = kmalloc(inline_size, GFP_NOFS);
+       if (!tmp)
+               return -ENOMEM;
        ptr = btrfs_file_extent_inline_start(item);
  
        read_extent_buffer(leaf, tmp, ptr, inline_size);
@@@ -6036,7 -6043,7 +6041,7 @@@ static int btrfs_submit_direct_hook(in
        ret = btrfs_map_block(map_tree, READ, start_sector << 9,
                              &map_length, NULL, 0);
        if (ret) {
-               bio_put(bio);
+               bio_put(orig_bio);
                return -EIO;
        }
  
@@@ -7273,11 -7280,12 +7278,12 @@@ static int btrfs_symlink(struct inode *
                                dentry->d_name.len, dir->i_ino, objectid,
                                BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,
                                &index);
-       err = PTR_ERR(inode);
-       if (IS_ERR(inode))
+       if (IS_ERR(inode)) {
+               err = PTR_ERR(inode);
                goto out_unlock;
+       }
  
 -      err = btrfs_init_inode_security(trans, inode, dir);
 +      err = btrfs_init_inode_security(trans, inode, dir, &dentry->d_name);
        if (err) {
                drop_inode = 1;
                goto out_unlock;
@@@ -7513,6 -7521,7 +7519,6 @@@ static const struct address_space_opera
        .writepage      = btrfs_writepage,
        .writepages     = btrfs_writepages,
        .readpages      = btrfs_readpages,
 -      .sync_page      = block_sync_page,
        .direct_IO      = btrfs_direct_IO,
        .invalidatepage = btrfs_invalidatepage,
        .releasepage    = btrfs_releasepage,