Message ID | 20191205165739.18381-1-fdmanana@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] Btrfs: fix cloning range with a hole when using the NO_HOLES feature | expand |
On Thu, Dec 05, 2019 at 04:57:39PM +0000, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > V2: Fixed the logic, it was broken except for trivial cases. Patch replaced, thanks.
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 0cb43b682789..8d47c76b7bd1 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2599,8 +2599,8 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path, } } - if (clone_info) { - u64 clone_len = drop_end - cur_offset; + if (clone_info && drop_end > clone_info->file_offset) { + u64 clone_len = drop_end - clone_info->file_offset; ret = btrfs_insert_clone_extent(trans, inode, path, clone_info, clone_len);