diff options
author | Dave Chinner <dchinner@redhat.com> | 2014-09-23 22:55:00 +1000 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-09-23 22:55:00 +1000 |
commit | 2ebff7bbd785c86e12956388b9e6f6bb8ea5d21e (patch) | |
tree | c0a3d0cec84187bdf66c674294d67e1416484996 /fs/nfs/Kconfig | |
parent | 7abbb8f928e5b7cea1edd077131b2ace665c6712 (diff) |
xfs: flush entire last page of old EOF on truncate up
On a sub-page sized filesystem, truncating a mapped region down
leaves us in a world of hurt. We truncate the pagecache, zeroing the
newly unused tail, then punch blocks out from under the page. If we
then truncate the file back up immediately, we expose that unmapped
hole to a dirty page mapped into the user application, and that's
where it all goes wrong.
In truncating the page cache, we avoid unmapping the tail page of
the cache because it still contains valid data. The problem is that
it also contains a hole after the truncate, but nobody told the mm
subsystem that. Therefore, if the page is dirty before the truncate,
we'll never get a .page_mkwrite callout after we extend the file and
the application writes data into the hole on the page. Hence when
we come to writing that region of the page, it has no blocks and no
delayed allocation reservation and hence we toss the data away.
This patch adds code to the truncate up case to solve it, by
ensuring the partial page at the old EOF is always cleaned after we
do any zeroing and move the EOF upwards. We can't actually serialise
the page writeback and truncate against page faults (yes, that
problem AGAIN) so this is really just a best effort and assumes it
is extremely unlikely that someone is concurrently writing to the
page at the EOF while extending the file.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/nfs/Kconfig')
0 files changed, 0 insertions, 0 deletions