gfs2: Do not call iomap_zero_range beyond eof
authorAndreas Gruenbacher <agruenba@redhat.com>
Wed, 7 May 2025 19:05:40 +0000 (21:05 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 22 May 2025 07:12:26 +0000 (09:12 +0200)
commit87faee382d294a35f3dad06dd0c27cdbee12cb97
treec4911f1316ca8ea6be477188f340e7350bfa3031
parente9a4af22af8fad2dd779e16759d86fb4cf037a73
gfs2: Do not call iomap_zero_range beyond eof

Since commit eb65540aa9fc ("iomap: warn on zero range of a post-eof
folio"), iomap_zero_range() warns when asked to zero a folio beyond eof.
The warning triggers on the following code path:

  gfs2_fallocate(FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE)
    __gfs2_punch_hole()
      gfs2_block_zero_range()
        iomap_zero_range()

In __gfs2_punch_hole(), gfs2 zeroes out partial folios at the beginning
and at the end of the specified range, whether those folios are beyond
eof or not.  This may add folios to the page cache which are entirely
beyond eof, which isn't of any use.  Avoid that by truncating the range
to zero out at eof.

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