Btrfs: add a incompatible format change for smaller metadata extent refs
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / inode.c
index 6a6e13c53086bef53884181fe0ae5aeda05192b6..c69145b66ea449c8767fd200a28ad31611954fa0 100644 (file)
@@ -1757,8 +1757,10 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
        struct btrfs_ordered_sum *sum;
 
        list_for_each_entry(sum, list, list) {
+               trans->adding_csums = 1;
                btrfs_csum_file_blocks(trans,
                       BTRFS_I(inode)->root->fs_info->csum_root, sum);
+               trans->adding_csums = 0;
        }
        return 0;
 }
@@ -2817,7 +2819,7 @@ static int btrfs_readpage_end_io_hook(struct page *page, u64 start, u64 end,
        if (ret)
                goto zeroit;
 
-       csum = btrfs_csum_data(root, kaddr + offset, csum,  end - start + 1);
+       csum = btrfs_csum_data(kaddr + offset, csum,  end - start + 1);
        btrfs_csum_final(csum, (char *)&csum);
        if (csum != private)
                goto zeroit;
@@ -3658,7 +3660,7 @@ static int check_path_shared(struct btrfs_root *root,
                eb = path->nodes[level];
                if (!btrfs_block_can_be_shared(root, eb))
                        continue;
-               ret = btrfs_lookup_extent_info(NULL, root, eb->start, eb->len,
+               ret = btrfs_lookup_extent_info(NULL, root, eb->start, level, 1,
                                               &refs, NULL);
                if (refs > 1)
                        return 1;
@@ -3693,11 +3695,9 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir,
         * 1 for the dir item
         * 1 for the dir index
         * 1 for the inode ref
-        * 1 for the inode ref in the tree log
-        * 2 for the dir entries in the log
         * 1 for the inode
         */
-       trans = btrfs_start_transaction(root, 8);
+       trans = btrfs_start_transaction(root, 5);
        if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC)
                return trans;
 
@@ -5124,7 +5124,7 @@ unsigned char btrfs_filetype_table[] = {
 static int btrfs_real_readdir(struct file *filp, void *dirent,
                              filldir_t filldir)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = file_inode(filp);
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_item *item;
        struct btrfs_dir_item *di;
@@ -6919,7 +6919,6 @@ static void btrfs_endio_direct_read(struct bio *bio, int err)
        struct bio_vec *bvec_end = bio->bi_io_vec + bio->bi_vcnt - 1;
        struct bio_vec *bvec = bio->bi_io_vec;
        struct inode *inode = dip->inode;
-       struct btrfs_root *root = BTRFS_I(inode)->root;
        u64 start;
 
        start = dip->logical_offset;
@@ -6936,7 +6935,7 @@ static void btrfs_endio_direct_read(struct bio *bio, int err)
                                goto failed;
                        local_irq_save(flags);
                        kaddr = kmap_atomic(page);
-                       csum = btrfs_csum_data(root, kaddr + bvec->bv_offset,
+                       csum = btrfs_csum_data(kaddr + bvec->bv_offset,
                                               csum, bvec->bv_len);
                        btrfs_csum_final(csum, (char *)&csum);
                        kunmap_atomic(kaddr);
@@ -7546,7 +7545,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned long offset)
 int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        struct page *page = vmf->page;
-       struct inode *inode = fdentry(vma->vm_file)->d_inode;
+       struct inode *inode = file_inode(vma->vm_file);
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
        struct btrfs_ordered_extent *ordered;
@@ -8141,7 +8140,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
         * inodes.  So 5 * 2 is 10, plus 1 for the new link, so 11 total items
         * should cover the worst case number of items we'll modify.
         */
-       trans = btrfs_start_transaction(root, 20);
+       trans = btrfs_start_transaction(root, 11);
        if (IS_ERR(trans)) {
                 ret = PTR_ERR(trans);
                 goto out_notrans;