summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong2019-07-19 01:06:09 +0200
committerGreg Kroah-Hartman2019-07-26 09:14:28 +0200
commit788920d12b95398f7cfe0022dd1021f31bc7ed76 (patch)
tree6f719487949221d2addc7beb3c1b3110adf7f764 /fs
parentinclude/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT archit... (diff)
downloadkernel-qcow2-linux-788920d12b95398f7cfe0022dd1021f31bc7ed76.tar.gz
kernel-qcow2-linux-788920d12b95398f7cfe0022dd1021f31bc7ed76.tar.xz
kernel-qcow2-linux-788920d12b95398f7cfe0022dd1021f31bc7ed76.zip
xfs: fix pagecache truncation prior to reflink
commit 4918ef4ea008cd2ff47eb852894e3f9b9047f4f3 upstream. Prior to remapping blocks, it is necessary to remove pages from the destination file's page cache. Unfortunately, the truncation is not aggressive enough -- if page size > block size, we'll end up zeroing subpage blocks instead of removing them. So, round the start offset down and the end offset up to page boundaries. We already wrote all the dirty data so the larger range shouldn't be a problem. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_reflink.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 7088f44c0c59..38ea08a3dd1d 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -1369,8 +1369,9 @@ xfs_reflink_remap_prep(
goto out_unlock;
/* Zap any page cache for the destination file's range. */
- truncate_inode_pages_range(&inode_out->i_data, pos_out,
- PAGE_ALIGN(pos_out + *len) - 1);
+ truncate_inode_pages_range(&inode_out->i_data,
+ round_down(pos_out, PAGE_SIZE),
+ round_up(pos_out + *len, PAGE_SIZE) - 1);
/* If we're altering the file contents... */
if (!is_dedupe) {