Skip to content

Commit 87faee3

Browse files
author
Andreas Gruenbacher
committed
gfs2: Do not call iomap_zero_range beyond eof
Since commit eb65540 ("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 <[email protected]>
1 parent e9a4af2 commit 87faee3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/gfs2/bmap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,10 +1296,12 @@ int gfs2_alloc_extent(struct inode *inode, u64 lblock, u64 *dblock,
12961296
* uses iomap write to perform its actions, which begin their own transactions
12971297
* (iomap_begin, get_folio, etc.)
12981298
*/
1299-
static int gfs2_block_zero_range(struct inode *inode, loff_t from,
1300-
unsigned int length)
1299+
static int gfs2_block_zero_range(struct inode *inode, loff_t from, loff_t length)
13011300
{
13021301
BUG_ON(current->journal_info);
1302+
if (from >= inode->i_size)
1303+
return 0;
1304+
length = min(length, inode->i_size - from);
13031305
return iomap_zero_range(inode, from, length, NULL, &gfs2_iomap_ops,
13041306
NULL);
13051307
}

0 commit comments

Comments
 (0)