From: Li Zefan Date: Sun, 11 Sep 2011 14:52:25 +0000 (-0400) Subject: Btrfs: add dummy extent if dst offset excceeds file end in X-Git-Tag: v3.12-rc1~4691^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d525e8ab022cb000e6e31a515ba8c3cf0d9c6130;p=kernel%2Fkernel-generic.git Btrfs: add dummy extent if dst offset excceeds file end in You can see there's no file extent with range [0, 4096]. Check this by btrfsck: # btrfsck /dev/sda7 root 5 inode 258 errors 100 ... Signed-off-by: Li Zefan Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 028a4b8..63b4de1 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2228,6 +2228,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, !IS_ALIGNED(destoff, bs)) goto out_unlock; + if (destoff > inode->i_size) { + ret = btrfs_cont_expand(inode, inode->i_size, destoff); + if (ret) + goto out_unlock; + } + /* do any pending delalloc/csum calc on src, one way or another, and lock file content */ while (1) {