Skip to content

Commit

Permalink
btrfs: use btrfs_ordered_update_i_size in clone_finish_inode_update
Browse files Browse the repository at this point in the history
We were using btrfs_i_size_write(), which unconditionally jacks up
inode->disk_i_size.  However since clone can operate on ranges we could
have pending ordered extents for a range prior to the start of our clone
operation and thus increase disk_i_size too far and have a hole with no
file extent.

Fix this by using the btrfs_ordered_update_i_size helper which will do
the right thing in the face of pending ordered extents outside of our
clone range.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Josef Bacik authored and David Sterba committed Mar 23, 2020
1 parent cfe953c commit 790a1d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3321,8 +3321,10 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
*/
if (endoff > destoff + olen)
endoff = destoff + olen;
if (endoff > inode->i_size)
btrfs_i_size_write(BTRFS_I(inode), endoff);
if (endoff > inode->i_size) {
i_size_write(inode, endoff);
btrfs_ordered_update_i_size(inode, endoff, NULL);
}

ret = btrfs_update_inode(trans, root, inode);
if (ret) {
Expand Down

0 comments on commit 790a1d4

Please sign in to comment.