Commit d72c0842 authored by Li Zefan's avatar Li Zefan Committed by Chris Mason

Btrfs: calc file extent num_bytes correctly in file clone

num_bytes should be 4096 not 12288.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 4815053a
...@@ -2333,14 +2333,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, ...@@ -2333,14 +2333,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
if (type == BTRFS_FILE_EXTENT_REG || if (type == BTRFS_FILE_EXTENT_REG ||
type == BTRFS_FILE_EXTENT_PREALLOC) { type == BTRFS_FILE_EXTENT_PREALLOC) {
/*
* a | --- range to clone ---| b
* | ------------- extent ------------- |
*/
/* substract range b */
if (key.offset + datal > off + len)
datal = off + len - key.offset;
/* substract range a */
if (off > key.offset) { if (off > key.offset) {
datao += off - key.offset; datao += off - key.offset;
datal -= off - key.offset; datal -= off - key.offset;
} }
if (key.offset + datal > off + len)
datal = off + len - key.offset;
ret = btrfs_drop_extents(trans, inode, ret = btrfs_drop_extents(trans, inode,
new_key.offset, new_key.offset,
new_key.offset + datal, new_key.offset + datal,
......
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