diff options
author | Chandan Rajendra <chandan@linux.vnet.ibm.com> | 2016-01-21 13:26:04 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-02-01 21:24:29 +0300 |
commit | 65bfa6580791f8c01fbc9cd8bd73d92aea53723f (patch) | |
tree | ecb54b0207e6e84cd109b4537a41266d1203cce7 /fs/btrfs/ioctl.c | |
parent | 27772b68f6994f0011690899c31717b7cbec51c9 (diff) | |
download | linux-65bfa6580791f8c01fbc9cd8bd73d92aea53723f.tar.xz |
Btrfs: btrfs_ioctl_clone: Truncate complete page after performing clone operation
In subpagesize-blocksize scenario, the "destination offset" argument passed to
the btrfs_ioctl_clone() can be aligned to sectorsize but may not be
necessarily aligned to the machine's page size. In such cases,
truncate_inode_pages_range() ends up zeroing out the partial page and future
read operations will return incorrect data. Hence this commit explicitly
rounds down the "destination offset" to the machine's page size.
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 83c9ad3f2621..709419c98ca5 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3926,8 +3926,9 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, * Truncate page cache pages so that future reads will see the cloned * data immediately and not the previous data. */ - truncate_inode_pages_range(&inode->i_data, destoff, - PAGE_CACHE_ALIGN(destoff + len) - 1); + truncate_inode_pages_range(&inode->i_data, + round_down(destoff, PAGE_CACHE_SIZE), + round_up(destoff + len, PAGE_CACHE_SIZE) - 1); out_unlock: if (!same_inode) btrfs_double_inode_unlock(src, inode); |