aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2011-09-21 03:48:33 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-09-21 03:48:33 -0400
commitf70cac8d9c7125f83048f8b3d1c60f5a041a165c (patch)
tree0d0efd72c1a41f973a919b16aac1d8210ed1ee30 /fs/btrfs/ioctl.c
parent4722cd7741c6404f967f7a7b8b666540b6c1663e (diff)
parent08aab447c56a5388cf0c768da476ad022f00fef8 (diff)
Merge branch 'kprobes-test' of git://git.yxit.co.uk/linux into devel-stable
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 970977aab224..3351b1b24574 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2220,6 +2220,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
2220 !IS_ALIGNED(destoff, bs)) 2220 !IS_ALIGNED(destoff, bs))
2221 goto out_unlock; 2221 goto out_unlock;
2222 2222
2223 if (destoff > inode->i_size) {
2224 ret = btrfs_cont_expand(inode, inode->i_size, destoff);
2225 if (ret)
2226 goto out_unlock;
2227 }
2228
2223 /* do any pending delalloc/csum calc on src, one way or 2229 /* do any pending delalloc/csum calc on src, one way or
2224 another, and lock file content */ 2230 another, and lock file content */
2225 while (1) { 2231 while (1) {
@@ -2325,14 +2331,21 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
2325 2331
2326 if (type == BTRFS_FILE_EXTENT_REG || 2332 if (type == BTRFS_FILE_EXTENT_REG ||
2327 type == BTRFS_FILE_EXTENT_PREALLOC) { 2333 type == BTRFS_FILE_EXTENT_PREALLOC) {
2334 /*
2335 * a | --- range to clone ---| b
2336 * | ------------- extent ------------- |
2337 */
2338
2339 /* substract range b */
2340 if (key.offset + datal > off + len)
2341 datal = off + len - key.offset;
2342
2343 /* substract range a */
2328 if (off > key.offset) { 2344 if (off > key.offset) {
2329 datao += off - key.offset; 2345 datao += off - key.offset;
2330 datal -= off - key.offset; 2346 datal -= off - key.offset;
2331 } 2347 }
2332 2348
2333 if (key.offset + datal > off + len)
2334 datal = off + len - key.offset;
2335
2336 ret = btrfs_drop_extents(trans, inode, 2349 ret = btrfs_drop_extents(trans, inode,
2337 new_key.offset, 2350 new_key.offset,
2338 new_key.offset + datal, 2351 new_key.offset + datal,