Commit fb870f6c authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: remove item_size member of struct btrfs_clone_extent_info

The value of item_size of struct btrfs_clone_extent_info is always set to
the size of a non-inline file extent item, and in fact the infrastructure
that uses this structure (btrfs_punch_hole_range()) does not work with
inline file extents at all (and it is not supposed to).

So just remove that field from the structure and use directly
sizeof(struct btrfs_file_extent_item) instead. Also assert that the
file extent type is not inline at btrfs_insert_clone_extent().
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 8fccebfa
...@@ -1200,8 +1200,8 @@ struct btrfs_clone_extent_info { ...@@ -1200,8 +1200,8 @@ struct btrfs_clone_extent_info {
u64 data_offset; u64 data_offset;
u64 data_len; u64 data_len;
u64 file_offset; u64 file_offset;
/* Pointer to a file extent item of type regular or prealloc. */
char *extent_buf; char *extent_buf;
u32 item_size;
/* /*
* Set to true when attempting to replace a file range with a new extent * Set to true when attempting to replace a file range with a new extent
* described by this structure, set to false when attempting to clone an * described by this structure, set to false when attempting to clone an
......
...@@ -2596,15 +2596,16 @@ static int btrfs_insert_clone_extent(struct btrfs_trans_handle *trans, ...@@ -2596,15 +2596,16 @@ static int btrfs_insert_clone_extent(struct btrfs_trans_handle *trans,
key.type = BTRFS_EXTENT_DATA_KEY; key.type = BTRFS_EXTENT_DATA_KEY;
key.offset = clone_info->file_offset; key.offset = clone_info->file_offset;
ret = btrfs_insert_empty_item(trans, root, path, &key, ret = btrfs_insert_empty_item(trans, root, path, &key,
clone_info->item_size); sizeof(struct btrfs_file_extent_item));
if (ret) if (ret)
return ret; return ret;
leaf = path->nodes[0]; leaf = path->nodes[0];
slot = path->slots[0]; slot = path->slots[0];
write_extent_buffer(leaf, clone_info->extent_buf, write_extent_buffer(leaf, clone_info->extent_buf,
btrfs_item_ptr_offset(leaf, slot), btrfs_item_ptr_offset(leaf, slot),
clone_info->item_size); sizeof(struct btrfs_file_extent_item));
extent = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item); extent = btrfs_item_ptr(leaf, slot, struct btrfs_file_extent_item);
ASSERT(btrfs_file_extent_type(leaf, extent) != BTRFS_FILE_EXTENT_INLINE);
btrfs_set_file_extent_offset(leaf, extent, clone_info->data_offset); btrfs_set_file_extent_offset(leaf, extent, clone_info->data_offset);
btrfs_set_file_extent_num_bytes(leaf, extent, clone_len); btrfs_set_file_extent_num_bytes(leaf, extent, clone_len);
if (clone_info->is_new_extent) if (clone_info->is_new_extent)
......
...@@ -9617,7 +9617,6 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent( ...@@ -9617,7 +9617,6 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
extent_info.data_len = len; extent_info.data_len = len;
extent_info.file_offset = file_offset; extent_info.file_offset = file_offset;
extent_info.extent_buf = (char *)&stack_fi; extent_info.extent_buf = (char *)&stack_fi;
extent_info.item_size = sizeof(stack_fi);
extent_info.is_new_extent = true; extent_info.is_new_extent = true;
extent_info.qgroup_reserved = ret; extent_info.qgroup_reserved = ret;
extent_info.insertions = 0; extent_info.insertions = 0;
......
...@@ -462,7 +462,6 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -462,7 +462,6 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
clone_info.data_len = datal; clone_info.data_len = datal;
clone_info.file_offset = new_key.offset; clone_info.file_offset = new_key.offset;
clone_info.extent_buf = buf; clone_info.extent_buf = buf;
clone_info.item_size = size;
clone_info.is_new_extent = false; clone_info.is_new_extent = false;
ret = btrfs_punch_hole_range(inode, path, drop_start, ret = btrfs_punch_hole_range(inode, path, drop_start,
new_key.offset + datal - 1, &clone_info, new_key.offset + datal - 1, &clone_info,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment