aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-01-26 01:10:43 -0500
committerLi Zefan <lizf@cn.fujitsu.com>2011-01-26 12:11:18 -0500
commit4d728ec7aefdca5419d2ebfb28c147e81a4b59f4 (patch)
tree19dc56836d053c04d796ddca126dd60232175bb0 /fs/btrfs
parentb897abec032deb7cc3ce67392a1f544ac965ddea (diff)
Btrfs: Fix file clone when source offset is not 0
Suppose: - the source extent is: [0, 100] - the src offset is 10 - the clone length is 90 - the dest offset is 0 This statement: new_key.offset = key.offset + destoff - off will produce such an extent for the dest file: [ino, BTRFS_EXTENT_DATA_KEY, -10] , which is obviously wrong. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ioctl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f87552a1d7ea..1b61dab64062 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1788,7 +1788,10 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1788 1788
1789 memcpy(&new_key, &key, sizeof(new_key)); 1789 memcpy(&new_key, &key, sizeof(new_key));
1790 new_key.objectid = inode->i_ino; 1790 new_key.objectid = inode->i_ino;
1791 new_key.offset = key.offset + destoff - off; 1791 if (off <= key.offset)
1792 new_key.offset = key.offset + destoff - off;
1793 else
1794 new_key.offset = destoff;
1792 1795
1793 trans = btrfs_start_transaction(root, 1); 1796 trans = btrfs_start_transaction(root, 1);
1794 if (IS_ERR(trans)) { 1797 if (IS_ERR(trans)) {