From: Luis Chamberlain <mcgrof@kernel.org>
To: linux-xfs@vger.kernel.org, gregkh@linuxfoundation.org,
Alexander.Levin@microsoft.com
Cc: amir73il@gmail.com, hch@infradead.org,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 09/10] xfs: fix PAGE_MASK usage in xfs_free_file_space
Date: Thu, 31 Jan 2019 10:09:18 -0800 [thread overview]
Message-ID: <20190131180919.2500-10-mcgrof@kernel.org> (raw)
In-Reply-To: <20190131180919.2500-1-mcgrof@kernel.org>
From: "Darrick J. Wong" <darrick.wong@oracle.com>
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>
---
fs/xfs/xfs_bmap_util.c | 4 ++--
1 file 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;
--
2.18.0
next prev parent reply other threads:[~2019-01-31 18:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 18:09 [PATCH 00/10] xfs: stable fixes for v4.19.y Luis Chamberlain
2019-01-31 18:09 ` [PATCH 01/10] xfs: Fix xqmstats offsets in /proc/fs/xfs/xqmstat Luis Chamberlain
2019-01-31 18:19 ` Greg KH
2019-01-31 18:26 ` Luis Chamberlain
2019-01-31 18:09 ` [PATCH 02/10] xfs: cancel COW blocks before swapext Luis Chamberlain
2019-01-31 18:09 ` [PATCH 03/10] xfs: Fix error code in 'xfs_ioc_getbmap()' Luis Chamberlain
2019-01-31 18:09 ` [PATCH 04/10] xfs: fix overflow in xfs_attr3_leaf_verify Luis Chamberlain
2019-01-31 18:09 ` [PATCH 05/10] xfs: fix shared extent data corruption due to missing cow reservation Luis Chamberlain
2019-01-31 18:09 ` [PATCH 06/10] xfs: fix transient reference count error in xfs_buf_resubmit_failed_buffers Luis Chamberlain
2019-01-31 18:09 ` [PATCH 07/10] xfs: delalloc -> unwritten COW fork allocation can go wrong Luis Chamberlain
2019-01-31 18:09 ` [PATCH 08/10] fs/xfs: fix f_ffree value for statfs when project quota is set Luis Chamberlain
2019-01-31 18:09 ` Luis Chamberlain [this message]
2019-01-31 18:09 ` [PATCH 10/10] xfs: fix inverted return from xfs_btree_sblock_verify_crc Luis Chamberlain
2019-01-31 18:20 ` [PATCH 00/10] xfs: stable fixes for v4.19.y Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190131180919.2500-10-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=Alexander.Levin@microsoft.com \
--cc=amir73il@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).