gfs2: Improve mmap write vs. punch_hole consistency
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 6 Sep 2019 13:51:38 +0000 (14:51 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 7 Nov 2019 20:01:04 +0000 (21:01 +0100)
commit39c3a948ecf6e7b8f55f0e91a5febc924fede4d7
treea02ce92211f2dd75fbe0e92b9a1b751c3595d785
parent1a48049adb98a20fad05ed86bc00c2f9120a006e
gfs2: Improve mmap write vs. punch_hole consistency

When punching a hole in a file, use filemap_write_and_wait_range to
write back any dirty pages in the range of the hole.  As a side effect,
if the hole isn't page aligned, this marks unaligned pages at the
beginning and the end of the hole read-only.  This is required when the
block size is smaller than the page size: when those pages are written
to again after the hole punching, we must make sure that page_mkwrite is
called for those pages so that the page will be fully allocated and any
blocks turned into holes from the hole punching will be reallocated.
(If a page is writably mapped, page_mkwrite won't be called.)

Fixes xfstest generic/567.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/bmap.c