xfs: fix pagecache truncation prior to reflink
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 18 Jul 2019 23:06:09 +0000 (23:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:14:28 +0000 (09:14 +0200)
commit788920d12b95398f7cfe0022dd1021f31bc7ed76
tree6f719487949221d2addc7beb3c1b3110adf7f764
parent41f64437f030dc56b738afaa3b3ba7cf9e4064d6
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>
fs/xfs/xfs_reflink.c