Btrfs: make btrfs acls selectable
[safe/jmp/linux-2.6] / fs / btrfs / inode.c
index c0ca9c3..2bb65e9 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/statfs.h>
 #include <linux/compat.h>
 #include <linux/bit_spinlock.h>
-#include <linux/version.h>
 #include <linux/xattr.h>
 #include <linux/posix_acl.h>
 #include <linux/falloc.h>
@@ -157,7 +156,6 @@ static noinline int insert_inline_extent(struct btrfs_trans_handle *trans,
        key.objectid = inode->i_ino;
        key.offset = start;
        btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY);
-       inode_add_bytes(inode, size);
        datasize = btrfs_file_extent_calc_inline_size(cur_size);
 
        inode_add_bytes(inode, size);
@@ -920,8 +918,8 @@ static noinline int csum_exist_in_range(struct btrfs_root *root,
        struct btrfs_ordered_sum *sums;
        LIST_HEAD(list);
 
-       ret = btrfs_lookup_csums_range(root, bytenr, bytenr + num_bytes - 1,
-                                      &list);
+       ret = btrfs_lookup_csums_range(root->fs_info->csum_root, bytenr,
+                                      bytenr + num_bytes - 1, &list);
        if (ret == 0 && list_empty(&list))
                return 0;
 
@@ -1325,12 +1323,11 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
                             struct inode *inode, u64 file_offset,
                             struct list_head *list)
 {
-       struct list_head *cur;
        struct btrfs_ordered_sum *sum;
 
        btrfs_set_trans_block_group(trans, inode);
-       list_for_each(cur, list) {
-               sum = list_entry(cur, struct btrfs_ordered_sum, list);
+
+       list_for_each_entry(sum, list, list) {
                btrfs_csum_file_blocks(trans,
                       BTRFS_I(inode)->root->fs_info->csum_root, sum);
        }
@@ -1728,7 +1725,6 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
        int ret;
        struct btrfs_root *root = BTRFS_I(inode)->root;
        u32 csum = ~(u32)0;
-       unsigned long flags;
 
        if (PageChecked(page)) {
                ClearPageChecked(page);
@@ -1750,8 +1746,7 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
        } else {
                ret = get_state_private(io_tree, start, &private);
        }
-       local_irq_save(flags);
-       kaddr = kmap_atomic(page, KM_IRQ0);
+       kaddr = kmap_atomic(page, KM_USER0);
        if (ret)
                goto zeroit;
 
@@ -1760,8 +1755,7 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
        if (csum != private)
                goto zeroit;
 
-       kunmap_atomic(kaddr, KM_IRQ0);
-       local_irq_restore(flags);
+       kunmap_atomic(kaddr, KM_USER0);
 good:
        /* if the io failure tree for this inode is non-empty,
         * check to see if we've recovered from a failed IO
@@ -1776,8 +1770,7 @@ zeroit:
               (unsigned long long)private);
        memset(kaddr + offset, 1, end - start + 1);
        flush_dcache_page(page);
-       kunmap_atomic(kaddr, KM_IRQ0);
-       local_irq_restore(flags);
+       kunmap_atomic(kaddr, KM_USER0);
        if (private == 0)
                return 0;
        return -EIO;
@@ -3270,7 +3263,7 @@ skip:
 
        /* Reached end of directory/root. Bump pos past the last item. */
        if (key_type == BTRFS_DIR_INDEX_KEY)
-               filp->f_pos = INT_LIMIT(typeof(filp->f_pos));
+               filp->f_pos = INT_LIMIT(off_t);
        else
                filp->f_pos++;
 nopos:
@@ -4163,9 +4156,10 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
        return -EINVAL;
 }
 
-static sector_t btrfs_bmap(struct address_space *mapping, sector_t iblock)
+static int btrfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+               __u64 start, __u64 len)
 {
-       return extent_bmap(mapping, iblock, btrfs_get_extent);
+       return extent_fiemap(inode, fieinfo, start, len, btrfs_get_extent);
 }
 
 int btrfs_readpage(struct file *file, struct page *page)
@@ -4992,13 +4986,24 @@ static struct extent_io_ops btrfs_extent_io_ops = {
        .clear_bit_hook = btrfs_clear_bit_hook,
 };
 
+/*
+ * btrfs doesn't support the bmap operation because swapfiles
+ * use bmap to make a mapping of extents in the file.  They assume
+ * these extents won't change over the life of the file and they
+ * use the bmap result to do IO directly to the drive.
+ *
+ * the btrfs bmap call would return logical addresses that aren't
+ * suitable for IO and they also will change frequently as COW
+ * operations happen.  So, swapfile + btrfs == corruption.
+ *
+ * For now we're avoiding this by dropping bmap.
+ */
 static struct address_space_operations btrfs_aops = {
        .readpage       = btrfs_readpage,
        .writepage      = btrfs_writepage,
        .writepages     = btrfs_writepages,
        .readpages      = btrfs_readpages,
        .sync_page      = block_sync_page,
-       .bmap           = btrfs_bmap,
        .direct_IO      = btrfs_direct_IO,
        .invalidatepage = btrfs_invalidatepage,
        .releasepage    = btrfs_releasepage,
@@ -5022,6 +5027,7 @@ static struct inode_operations btrfs_file_inode_operations = {
        .removexattr    = btrfs_removexattr,
        .permission     = btrfs_permission,
        .fallocate      = btrfs_fallocate,
+       .fiemap         = btrfs_fiemap,
 };
 static struct inode_operations btrfs_special_inode_operations = {
        .getattr        = btrfs_getattr,