summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-09-11 10:52:25 -0400
committerChris Mason <chris.mason@oracle.com>2011-09-11 10:52:25 -0400
commitd72c0842ff0e71342857723bb65f35b71f57b264 (patch)
treeab0e5037f19fd279fb57b3b653a53d5c92f32e73 /fs/btrfs/ioctl.c
parent4815053aba7f2304055745df820cd74a39fdaab2 (diff)
downloadop-kernel-dev-d72c0842ff0e71342857723bb65f35b71f57b264.zip
op-kernel-dev-d72c0842ff0e71342857723bb65f35b71f57b264.tar.gz
Btrfs: calc file extent num_bytes correctly in file clone
num_bytes should be 4096 not 12288. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b3d249d..028a4b8 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2333,14 +2333,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
if (type == BTRFS_FILE_EXTENT_REG ||
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) {
datao += off - key.offset;
datal -= off - key.offset;
}
- if (key.offset + datal > off + len)
- datal = off + len - key.offset;
-
ret = btrfs_drop_extents(trans, inode,
new_key.offset,
new_key.offset + datal,
OpenPOWER on IntegriCloud