}
 
 static noinline int copy_items(struct btrfs_trans_handle *trans,
-                              struct btrfs_root *log,
+                              struct inode *inode,
                               struct btrfs_path *dst_path,
                               struct extent_buffer *src,
                               int start_slot, int nr, int inode_only)
 {
        unsigned long src_offset;
        unsigned long dst_offset;
+       struct btrfs_root *log = BTRFS_I(inode)->root->log_root;
        struct btrfs_file_extent_item *extent;
        struct btrfs_inode_item *inode_item;
        int ret;
        char *ins_data;
        int i;
        struct list_head ordered_sums;
+       int skip_csum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
 
        INIT_LIST_HEAD(&ordered_sums);
 
                 * or deletes of this inode don't have to relog the inode
                 * again
                 */
-               if (btrfs_key_type(ins_keys + i) == BTRFS_EXTENT_DATA_KEY) {
+               if (btrfs_key_type(ins_keys + i) == BTRFS_EXTENT_DATA_KEY &&
+                   !skip_csum) {
                        int found_type;
                        extent = btrfs_item_ptr(src, start_slot + i,
                                                struct btrfs_file_extent_item);
                    args->start_slot + args->nr == path->slots[0]) {
                        args->nr++;
                } else if (args->nr) {
-                       ret = copy_items(trans, log, dst_path, args->src,
+                       ret = copy_items(trans, inode, dst_path, args->src,
                                         args->start_slot, args->nr,
                                         LOG_INODE_ALL);
                        if (ret)
                }
 
                if (args->nr) {
-                       ret = copy_items(trans, log, dst_path, args->src,
+                       ret = copy_items(trans, inode, dst_path, args->src,
                                         args->start_slot, args->nr,
                                         LOG_INODE_ALL);
                        if (ret)
                                     struct btrfs_path *dst_path)
 {
        struct log_args args;
-       struct btrfs_root *log = root->log_root;
        struct extent_map *em, *n;
        struct list_head extents;
        struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree;
                 * our search
                 */
                if (args.nr && em->mod_start != args.next_offset) {
-                       ret = copy_items(trans, log, dst_path, args.src,
+                       ret = copy_items(trans, inode, dst_path, args.src,
                                         args.start_slot, args.nr,
                                         LOG_INODE_ALL);
                        if (ret)
        }
 
        if (!ret && args.nr)
-               ret = copy_items(trans, log, dst_path, args.src,
+               ret = copy_items(trans, inode, dst_path, args.src,
                                 args.start_slot, args.nr, LOG_INODE_ALL);
        btrfs_release_path(path);
        WARN_ON(!list_empty(&extents));
                        goto next_slot;
                }
 
-               ret = copy_items(trans, log, dst_path, src, ins_start_slot,
+               ret = copy_items(trans, inode, dst_path, src, ins_start_slot,
                                 ins_nr, inode_only);
                if (ret) {
                        err = ret;
                        goto again;
                }
                if (ins_nr) {
-                       ret = copy_items(trans, log, dst_path, src,
+                       ret = copy_items(trans, inode, dst_path, src,
                                         ins_start_slot,
                                         ins_nr, inode_only);
                        if (ret) {
                        break;
        }
        if (ins_nr) {
-               ret = copy_items(trans, log, dst_path, src,
-                                ins_start_slot,
+               ret = copy_items(trans, inode, dst_path, src, ins_start_slot,
                                 ins_nr, inode_only);
                if (ret) {
                        err = ret;