diff options
author | Darrick J. Wong | 2019-02-04 17:54:26 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2019-02-12 19:47:21 +0100 |
commit | c6c20af69c617121331e231f797893d9dca0c9c5 (patch) | |
tree | 71d94be20243ae18a0cceef76866a45b517c27c6 | |
parent | fs/xfs: fix f_ffree value for statfs when project quota is set (diff) | |
download | kernel-qcow2-linux-c6c20af69c617121331e231f797893d9dca0c9c5.tar.gz kernel-qcow2-linux-c6c20af69c617121331e231f797893d9dca0c9c5.tar.xz kernel-qcow2-linux-c6c20af69c617121331e231f797893d9dca0c9c5.zip |
xfs: fix PAGE_MASK usage in xfs_free_file_space
commit a579121f94aba4e8bad1a121a0fad050d6925296 upstream.
In commit e53c4b598, I *tried* to teach xfs to force writeback when we
fzero/fpunch right up to EOF so that if EOF is in the middle of a page,
the post-EOF part of the page gets zeroed before we return to userspace.
Unfortunately, I missed the part where PAGE_MASK is ~(PAGE_SIZE - 1),
which means that we totally fail to zero if we're fpunching and EOF is
within the first page. Worse yet, the same PAGE_MASK thinko plagues the
filemap_write_and_wait_range call, so we'd initiate writeback of the
entire file, which (mostly) masked the thinko.
Drop the tricky PAGE_MASK and replace it with correct usage of PAGE_SIZE
and the proper rounding macros.
Fixes: e53c4b598 ("xfs: ensure post-EOF zeroing happens after zeroing part of a file")
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: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 9d1e5c3a661e..211b06e4702e 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -1175,9 +1175,9 @@ xfs_free_file_space( * page could be mmap'd and iomap_zero_range doesn't do that for us. * Writeback of the eof page will do this, albeit clumsily. */ - if (offset + len >= XFS_ISIZE(ip) && ((offset + len) & PAGE_MASK)) { + if (offset + len >= XFS_ISIZE(ip) && offset_in_page(offset + len) > 0) { error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, - (offset + len) & ~PAGE_MASK, LLONG_MAX); + round_down(offset + len, PAGE_SIZE), LLONG_MAX); } return error; |