summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-10-09 17:29:53 +0200
committerChris Mason <chris.mason@oracle.com>2009-10-09 17:29:53 +0200
commitac6889cbb254be1ffea376bea4a96ce9be0e0ed0 (patch)
tree8f0e073af940b1bdfb134b945a03a1b43b614352 /fs/btrfs
parentBtrfs: fix uninit compiler warning in cow_file_range_nocow (diff)
downloadlinux-ac6889cbb254be1ffea376bea4a96ce9be0e0ed0.tar.xz
linux-ac6889cbb254be1ffea376bea4a96ce9be0e0ed0.zip
Btrfs: fix file clone ioctl for bookend extents
The file clone ioctl was incorrectly taking the offset into the extent on disk into account when calculating the length of the cloned extent. The length never changes based on the offset into the physical extent. Test case: fallocate -l 1g image mke2fs image bcp image image2 e2fsck -f image2 (errors on image2) The math bug ends up wrapping the length of the extent, and things go wrong from there. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ioctl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e8795becad4c..cdbb054102b9 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1123,8 +1123,10 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
datao += off - key.offset;
datal -= off - key.offset;
}
- if (key.offset + datao + datal > off + len)
- datal = off + len - key.offset - datao;
+
+ if (key.offset + datal > off + len)
+ datal = off + len - key.offset;
+
/* disko == 0 means it's a hole */
if (!disko)
datao = 0;