Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable

* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable:
Btrfs: apply updated fallocate i_size fix
Btrfs: do not try and lookup the file extent when finishing ordered io
Btrfs: Fix oopsen when dropping empty tree.
Btrfs: remove BUG_ON() due to mounting bad filesystem
Btrfs: make error return negative in btrfs_sync_file()
Btrfs: fix race between allocate and release extent buffer.

+19 -54
+6 -1
fs/btrfs/disk-io.c
··· 1982 1982 1983 1983 if (!(sb->s_flags & MS_RDONLY)) { 1984 1984 ret = btrfs_recover_relocation(tree_root); 1985 - BUG_ON(ret); 1985 + if (ret < 0) { 1986 + printk(KERN_WARNING 1987 + "btrfs: failed to recover relocation\n"); 1988 + err = -EINVAL; 1989 + goto fail_trans_kthread; 1990 + } 1986 1991 } 1987 1992 1988 1993 location.objectid = BTRFS_FS_TREE_OBJECTID;
+4 -4
fs/btrfs/extent-tree.c
··· 5402 5402 int ret; 5403 5403 5404 5404 while (level >= 0) { 5405 - if (path->slots[level] >= 5406 - btrfs_header_nritems(path->nodes[level])) 5407 - break; 5408 - 5409 5405 ret = walk_down_proc(trans, root, path, wc, lookup_info); 5410 5406 if (ret > 0) 5411 5407 break; 5412 5408 5413 5409 if (level == 0) 5410 + break; 5411 + 5412 + if (path->slots[level] >= 5413 + btrfs_header_nritems(path->nodes[level])) 5414 5414 break; 5415 5415 5416 5416 ret = do_walk_down(trans, root, path, wc, &lookup_info);
+1 -2
fs/btrfs/extent_io.c
··· 3165 3165 spin_unlock(&tree->buffer_lock); 3166 3166 goto free_eb; 3167 3167 } 3168 - spin_unlock(&tree->buffer_lock); 3169 - 3170 3168 /* add one reference for the tree */ 3171 3169 atomic_inc(&eb->refs); 3170 + spin_unlock(&tree->buffer_lock); 3172 3171 return eb; 3173 3172 3174 3173 free_eb:
+1 -1
fs/btrfs/file.c
··· 1133 1133 } 1134 1134 mutex_lock(&dentry->d_inode->i_mutex); 1135 1135 out: 1136 - return ret > 0 ? EIO : ret; 1136 + return ret > 0 ? -EIO : ret; 1137 1137 } 1138 1138 1139 1139 static const struct vm_operations_struct btrfs_file_vm_ops = {
+5 -45
fs/btrfs/inode.c
··· 1681 1681 * before we start the transaction. It limits the amount of btree 1682 1682 * reads required while inside the transaction. 1683 1683 */ 1684 - static noinline void reada_csum(struct btrfs_root *root, 1685 - struct btrfs_path *path, 1686 - struct btrfs_ordered_extent *ordered_extent) 1687 - { 1688 - struct btrfs_ordered_sum *sum; 1689 - u64 bytenr; 1690 - 1691 - sum = list_entry(ordered_extent->list.next, struct btrfs_ordered_sum, 1692 - list); 1693 - bytenr = sum->sums[0].bytenr; 1694 - 1695 - /* 1696 - * we don't care about the results, the point of this search is 1697 - * just to get the btree leaves into ram 1698 - */ 1699 - btrfs_lookup_csum(NULL, root->fs_info->csum_root, path, bytenr, 0); 1700 - } 1701 - 1702 1684 /* as ordered data IO finishes, this gets called so we can finish 1703 1685 * an ordered extent if the range of bytes in the file it covers are 1704 1686 * fully written. ··· 1691 1709 struct btrfs_trans_handle *trans; 1692 1710 struct btrfs_ordered_extent *ordered_extent = NULL; 1693 1711 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; 1694 - struct btrfs_path *path; 1695 1712 int compressed = 0; 1696 1713 int ret; 1697 1714 ··· 1698 1717 if (!ret) 1699 1718 return 0; 1700 1719 1701 - /* 1702 - * before we join the transaction, try to do some of our IO. 1703 - * This will limit the amount of IO that we have to do with 1704 - * the transaction running. We're unlikely to need to do any 1705 - * IO if the file extents are new, the disk_i_size checks 1706 - * covers the most common case. 1707 - */ 1708 - if (start < BTRFS_I(inode)->disk_i_size) { 1709 - path = btrfs_alloc_path(); 1710 - if (path) { 1711 - ret = btrfs_lookup_file_extent(NULL, root, path, 1712 - inode->i_ino, 1713 - start, 0); 1714 - ordered_extent = btrfs_lookup_ordered_extent(inode, 1715 - start); 1716 - if (!list_empty(&ordered_extent->list)) { 1717 - btrfs_release_path(root, path); 1718 - reada_csum(root, path, ordered_extent); 1719 - } 1720 - btrfs_free_path(path); 1721 - } 1722 - } 1723 - 1724 - if (!ordered_extent) 1725 - ordered_extent = btrfs_lookup_ordered_extent(inode, start); 1720 + ordered_extent = btrfs_lookup_ordered_extent(inode, start); 1726 1721 BUG_ON(!ordered_extent); 1722 + 1727 1723 if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { 1728 1724 BUG_ON(!list_empty(&ordered_extent->list)); 1729 1725 ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); ··· 5799 5841 inode->i_ctime = CURRENT_TIME; 5800 5842 BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; 5801 5843 if (!(mode & FALLOC_FL_KEEP_SIZE) && 5802 - cur_offset > inode->i_size) { 5844 + (actual_len > inode->i_size) && 5845 + (cur_offset > inode->i_size)) { 5846 + 5803 5847 if (cur_offset > actual_len) 5804 5848 i_size = actual_len; 5805 5849 else
+2 -1
fs/btrfs/relocation.c
··· 3764 3764 BTRFS_DATA_RELOC_TREE_OBJECTID); 3765 3765 if (IS_ERR(fs_root)) 3766 3766 err = PTR_ERR(fs_root); 3767 - btrfs_orphan_cleanup(fs_root); 3767 + else 3768 + btrfs_orphan_cleanup(fs_root); 3768 3769 } 3769 3770 return err; 3770 3771 }