diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index f4514ee273ce..696e095e7111 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -443,9 +443,9 @@ int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
 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,
-			      u64 *orig_block_len,
-			      u64 *ram_bytes, bool nowait, bool strict,
-			      u64 *disk_bytenr_ret, u64 *extent_offset_ret);
+			      u64 *disk_bytenr, u64 *disk_num_bytes,
+			      u64 *ram_bytes, u64 *new_offset_ret,
+			      bool nowait, bool strict);
 
 void btrfs_del_delalloc_inode(struct btrfs_inode *inode);
 struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 965d2ba34aeb..b3ba2d4f2b8b 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1094,7 +1094,7 @@ int btrfs_check_nocow_lock(struct btrfs_inode *inode, loff_t pos,
 						   &cached_state);
 	}
 	ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes,
-			NULL, NULL, nowait, false, NULL, NULL);
+			NULL, NULL, NULL, NULL, nowait, false);
 	if (ret <= 0)
 		btrfs_drew_write_unlock(&root->snapshot_lock);
 	else
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cbc40d291d76..0d9d743719e9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -139,9 +139,10 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode,
 				     bool pages_dirty);
 static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
 				       u64 len,
+				       u64 disk_bytenr,
 				       u64 disk_num_bytes,
-				       u64 ram_bytes, int compress_type,
-				       int type, u64 disk_bytenr, u64 offset);
+				       u64 ram_bytes, u64 offset, int compress_type,
+				       int type);
 
 static int data_reloc_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
 					  u64 root, void *warn_ctx)
@@ -1160,11 +1161,12 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
 	/* Here we're doing allocation and writeback of the compressed pages */
 	em = create_io_em(inode, start,
 			  async_extent->ram_size,	/* len */
-			  ins.offset,			/* orig_block_len */
+			  ins.objectid,			/* disk_bytenr */
+			  ins.offset,			/* disk_num_bytes */
 			  async_extent->ram_size,	/* ram_bytes */
+			  0,				/* offset */
 			  async_extent->compress_type,
-			  BTRFS_ORDERED_COMPRESSED,
-			  ins.objectid, 0);
+			  BTRFS_ORDERED_COMPRESSED);
 	if (IS_ERR(em)) {
 		ret = PTR_ERR(em);
 		goto out_free_reserve;
@@ -1421,11 +1423,12 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
 
 		ram_size = ins.offset;
 		em = create_io_em(inode, start, ins.offset, /* len */
+				  ins.objectid, /* disk_bytenr */
 				  ins.offset, /* orig_block_len */
 				  ram_size, /* ram_bytes */
+				  0, /* offset */
 				  BTRFS_COMPRESS_NONE, /* compress_type */
-				  BTRFS_ORDERED_REGULAR /* type */,
-				  ins.objectid, 0);
+				  BTRFS_ORDERED_REGULAR /* type */);
 		if (IS_ERR(em)) {
 			ret = PTR_ERR(em);
 			goto out_reserve;
@@ -2161,12 +2164,13 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
 			struct extent_map *em;
 
 			em = create_io_em(inode, cur_offset, nocow_args.num_bytes,
-					  nocow_args.orig_disk_num_bytes, /* orig_block_len */
-					  ram_bytes, BTRFS_COMPRESS_NONE,
-					  BTRFS_ORDERED_PREALLOC,
-					  nocow_args.orig_disk_bytenr,
+					  nocow_args.orig_disk_bytenr, /* disk_bytenr */
+					  nocow_args.orig_disk_num_bytes, /* disk_num_bytes */
+					  ram_bytes,
 					  cur_offset - found_key.offset +
-					  nocow_args.orig_offset);
+					  nocow_args.orig_offset, /* offset */
+					  BTRFS_COMPRESS_NONE,
+					  BTRFS_ORDERED_PREALLOC);
 			if (IS_ERR(em)) {
 				btrfs_dec_nocow_writers(nocow_bg);
 				ret = PTR_ERR(em);
@@ -7012,20 +7016,20 @@ static struct extent_map *btrfs_create_dio_extent(struct btrfs_inode *inode,
 						  struct btrfs_dio_data *dio_data,
 						  const u64 start,
 						  const u64 len,
-						  const u64 orig_block_len,
-						  const u64 ram_bytes,
-						  const int type,
 						  const u64 disk_bytenr,
-						  const u64 offset)
+						  const u64 disk_num_bytes,
+						  const u64 ram_bytes,
+						  const u64 offset,
+						  const int type)
 {
 	struct extent_map *em = NULL;
 	struct btrfs_ordered_extent *ordered;
 
 	if (type != BTRFS_ORDERED_NOCOW) {
 		em = create_io_em(inode, start, len,
-				  orig_block_len, ram_bytes,
+				  disk_bytenr, disk_num_bytes, ram_bytes, offset,
 				  BTRFS_COMPRESS_NONE, /* compress_type */
-				  type, disk_bytenr, offset);
+				  type);
 		if (IS_ERR(em))
 			goto out;
 	}
@@ -7074,10 +7078,13 @@ static struct extent_map *btrfs_new_extent_direct(struct btrfs_inode *inode,
 	if (ret)
 		return ERR_PTR(ret);
 
-	em = btrfs_create_dio_extent(inode, dio_data, start, ins.offset,
-				     ins.offset,
-				     ins.offset, BTRFS_ORDERED_REGULAR,
-				     ins.objectid, 0);
+	em = btrfs_create_dio_extent(inode, dio_data,
+				     start, ins.offset,
+				     ins.objectid, /* disk_bytenr */
+				     ins.offset, /* disk_num_bytes */
+				     ins.offset, /* ram_bytes */
+				     0, /* offset */
+				     BTRFS_ORDERED_REGULAR);
 	btrfs_dec_block_group_reservations(fs_info, ins.objectid);
 	if (IS_ERR(em))
 		btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset,
@@ -7120,9 +7127,9 @@ static bool btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr)
  *	 any ordered extents.
  */
 noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
-			      u64 *orig_block_len,
-			      u64 *ram_bytes, bool nowait, bool strict,
-			      u64 *disk_bytenr_ret, u64 *new_offset_ret)
+			      u64 *disk_bytenr, u64 *disk_num_bytes,
+			      u64 *ram_bytes, u64 *new_offset_ret,
+			      bool nowait, bool strict)
 {
 	struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
 	struct can_nocow_file_extent_args nocow_args = { 0 };
@@ -7207,10 +7214,10 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
 		}
 	}
 
-	if (orig_block_len)
-		*orig_block_len = nocow_args.orig_disk_num_bytes;
-	if (disk_bytenr_ret)
-		*disk_bytenr_ret = nocow_args.orig_disk_bytenr;
+	if (disk_bytenr)
+		*disk_bytenr = nocow_args.orig_disk_bytenr;
+	if (disk_num_bytes)
+		*disk_num_bytes = nocow_args.orig_disk_num_bytes;
 	if (new_offset_ret)
 		*new_offset_ret = offset - key.offset +
 				  nocow_args.orig_offset;
@@ -7318,9 +7325,12 @@ static int lock_extent_direct(struct inode *inode, u64 lockstart, u64 lockend,
 /* The callers of this must take lock_extent() */
 static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
 				       u64 len,
+				       u64 disk_bytenr,
 				       u64 disk_num_bytes,
-				       u64 ram_bytes, int compress_type,
-				       int type, u64 disk_bytenr, u64 offset)
+				       u64 ram_bytes,
+				       u64 offset,
+				       int compress_type,
+				       int type)
 {
 	struct extent_map *em;
 	int ret;
@@ -7428,8 +7438,9 @@ static int btrfs_get_blocks_direct_write(struct extent_map **map,
 		block_start = extent_map_block_start(em) + (start - em->start);
 
 		if (can_nocow_extent(inode, start, &len,
-				     &orig_block_len, &ram_bytes, false, false,
-				     &disk_bytenr, &new_offset) == 1) {
+				     &disk_bytenr, &orig_block_len,
+				     &ram_bytes, &new_offset,
+				     false, false) == 1) {
 			bg = btrfs_inc_nocow_writers(fs_info, block_start);
 			if (bg)
 				can_nocow = true;
@@ -7455,9 +7466,11 @@ static int btrfs_get_blocks_direct_write(struct extent_map **map,
 		space_reserved = true;
 
 		em2 = btrfs_create_dio_extent(BTRFS_I(inode), dio_data, start, len,
-					      orig_block_len,
-					      ram_bytes, type,
-					      disk_bytenr, new_offset);
+					      disk_bytenr, /* disk_bytenr. */
+					      orig_block_len, /* disk_num_bytes */
+					      ram_bytes, /* ram_bytes */
+					      new_offset, /* offset */
+					      type);
 		btrfs_dec_nocow_writers(bg);
 		if (type == BTRFS_ORDERED_PREALLOC) {
 			free_extent_map(em);
@@ -10515,9 +10528,9 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
 	extent_reserved = true;
 
 	em = create_io_em(inode, start, num_bytes,
-			  ins.offset, ram_bytes, compression,
-			  BTRFS_ORDERED_COMPRESSED, ins.objectid,
-			  encoded->unencoded_offset);
+			  ins.objectid, ins.offset, ram_bytes,
+			  encoded->unencoded_offset, compression,
+			  BTRFS_ORDERED_COMPRESSED);
 	if (IS_ERR(em)) {
 		ret = PTR_ERR(em);
 		goto out_free_reserved;
@@ -10847,8 +10860,8 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
 		free_extent_map(em);
 		em = NULL;
 
-		ret = can_nocow_extent(inode, start, &len, NULL, NULL,
-				       false, true, NULL, NULL);
+		ret = can_nocow_extent(inode, start, &len, NULL, NULL, NULL, NULL,
+				       false, true);
 		if (ret < 0) {
 			goto out;
 		} else if (ret) {
