]> asedeno.scripts.mit.edu Git - linux.git/commit
gfs2: Fix end-of-file handling in gfs2_page_mkwrite
authorAndreas Gruenbacher <agruenba@redhat.com>
Wed, 6 Nov 2019 14:09:25 +0000 (14:09 +0000)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 7 Nov 2019 20:02:35 +0000 (21:02 +0100)
commit184b4e60853dfeef36b96948ab8fedb7e271063c
tree490cc2893f4da8ab096ee66ad07a5491408b68ec
parentf53056c43063257ae4159d83c425eaeb772bcd71
gfs2: Fix end-of-file handling in gfs2_page_mkwrite

When the filesystem block size is smaller than the page size, the last
page may contain blocks that lie entirely beyond the end of the file.
Make sure to only allocate blocks that lie at least partially in the
file.  Allocating blocks beyond that isn't useful, and what's more, they
will not be zeroed out and may end up containing random data.

With that change in place, make sure we'll still always unstuff stuffed
inodes: iomap_writepage and iomap_writepages currently can't handle
stuffed files.

In addition, simplify and move the end-of-file check further to the top
in gfs2_page_mkwrite to avoid weird side effects like unstuffing when
we're not.

Fixes xfstest generic/263.

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