diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2011-09-11 10:52:25 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-09-11 10:52:25 -0400 |
commit | d72c0842ff0e71342857723bb65f35b71f57b264 (patch) | |
tree | ab0e5037f19fd279fb57b3b653a53d5c92f32e73 /fs/btrfs | |
parent | 4815053aba7f2304055745df820cd74a39fdaab2 (diff) |
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')
-rw-r--r-- | fs/btrfs/ioctl.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index b3d249d6eba7..028a4b8c12cd 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, | |||
2333 | 2333 | ||
2334 | if (type == BTRFS_FILE_EXTENT_REG || | 2334 | if (type == BTRFS_FILE_EXTENT_REG || |
2335 | type == BTRFS_FILE_EXTENT_PREALLOC) { | 2335 | type == BTRFS_FILE_EXTENT_PREALLOC) { |
2336 | /* | ||
2337 | * a | --- range to clone ---| b | ||
2338 | * | ------------- extent ------------- | | ||
2339 | */ | ||
2340 | |||
2341 | /* substract range b */ | ||
2342 | if (key.offset + datal > off + len) | ||
2343 | datal = off + len - key.offset; | ||
2344 | |||
2345 | /* substract range a */ | ||
2336 | if (off > key.offset) { | 2346 | if (off > key.offset) { |
2337 | datao += off - key.offset; | 2347 | datao += off - key.offset; |
2338 | datal -= off - key.offset; | 2348 | datal -= off - key.offset; |
2339 | } | 2349 | } |
2340 | 2350 | ||
2341 | if (key.offset + datal > off + len) | ||
2342 | datal = off + len - key.offset; | ||
2343 | |||
2344 | ret = btrfs_drop_extents(trans, inode, | 2351 | ret = btrfs_drop_extents(trans, inode, |
2345 | new_key.offset, | 2352 | new_key.offset, |
2346 | new_key.offset + datal, | 2353 | new_key.offset + datal, |