Commit 790a1d44 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: use btrfs_ordered_update_i_size in clone_finish_inode_update

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: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent cfe953c8
...@@ -3321,8 +3321,10 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans, ...@@ -3321,8 +3321,10 @@ static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
*/ */
if (endoff > destoff + olen) if (endoff > destoff + olen)
endoff = destoff + olen; endoff = destoff + olen;
if (endoff > inode->i_size) if (endoff > inode->i_size) {
btrfs_i_size_write(BTRFS_I(inode), endoff); i_size_write(inode, endoff);
btrfs_ordered_update_i_size(inode, endoff, NULL);
}
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
if (ret) { if (ret) {
......
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