u32 pgoff, u8 *csum, const u8 * const csum_expected);
 bool btrfs_data_csum_ok(struct btrfs_bio *bbio, struct btrfs_device *dev,
                        u32 bio_offset, struct bio_vec *bv);
-noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+noinline int can_nocow_extent(struct btrfs_inode *inode, u64 offset, u64 *len,
                              struct btrfs_file_extent *file_extent,
                              bool nowait);
 
 
                len = min(len, em->len - (start - em->start));
                block_start = extent_map_block_start(em) + (start - em->start);
 
-               if (can_nocow_extent(inode, start, &len, &file_extent, false) == 1) {
+               if (can_nocow_extent(BTRFS_I(inode), start, &len, &file_extent,
+                                    false) == 1) {
                        bg = btrfs_inc_nocow_writers(fs_info, block_start);
                        if (bg)
                                can_nocow = true;
 
                btrfs_lock_and_flush_ordered_range(inode, lockstart, lockend,
                                                   &cached_state);
        }
-       ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes,
-                              NULL, nowait);
+       ret = can_nocow_extent(inode, lockstart, &num_bytes, NULL, nowait);
        if (ret <= 0)
                btrfs_drew_write_unlock(&root->snapshot_lock);
        else
 
  * NOTE: This only checks the file extents, caller is responsible to wait for
  *      any ordered extents.
  */
-noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+noinline int can_nocow_extent(struct btrfs_inode *inode, u64 offset, u64 *len,
                              struct btrfs_file_extent *file_extent,
                              bool nowait)
 {
-       struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+       struct btrfs_root *root = inode->root;
+       struct btrfs_fs_info *fs_info = root->fs_info;
        struct can_nocow_file_extent_args nocow_args = { 0 };
        struct btrfs_path *path;
        int ret;
        struct extent_buffer *leaf;
-       struct btrfs_root *root = BTRFS_I(inode)->root;
-       struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
+       struct extent_io_tree *io_tree = &inode->io_tree;
        struct btrfs_file_extent_item *fi;
        struct btrfs_key key;
        int found_type;
                return -ENOMEM;
        path->nowait = nowait;
 
-       ret = btrfs_lookup_file_extent(NULL, root, path,
-                       btrfs_ino(BTRFS_I(inode)), offset, 0);
+       ret = btrfs_lookup_file_extent(NULL, root, path, btrfs_ino(inode),
+                                      offset, 0);
        if (ret < 0)
                goto out;
 
        ret = 0;
        leaf = path->nodes[0];
        btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
-       if (key.objectid != btrfs_ino(BTRFS_I(inode)) ||
+       if (key.objectid != btrfs_ino(inode) ||
            key.type != BTRFS_EXTENT_DATA_KEY) {
                /* not our file or wrong item type, must cow */
                goto out;
        nocow_args.end = offset + *len - 1;
        nocow_args.free_path = true;
 
-       ret = can_nocow_file_extent(path, &key, BTRFS_I(inode), &nocow_args);
+       ret = can_nocow_file_extent(path, &key, inode, &nocow_args);
        /* can_nocow_file_extent() has freed the path. */
        path = NULL;
 
                                  nocow_args.file_extent.offset))
                goto out;
 
-       if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW) &&
+       if (!(inode->flags & BTRFS_INODE_NODATACOW) &&
            found_type == BTRFS_FILE_EXTENT_PREALLOC) {
                u64 range_end;