From: Andreas Gruenbacher <agruenba@redhat.com>
To: Brian Foster <bfoster@redhat.com>,
Christian Brauner <brauner@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Matthew Wilcox <willy@infradead.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
gfs2@lists.linux.dev
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [RFC] gfs2: Do not call iomap_zero_range beyond eof
Date: Thu, 8 May 2025 15:34:27 +0200 [thread overview]
Message-ID: <20250508133427.3799322-1-agruenba@redhat.com> (raw)
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()
So far, gfs2 is just zeroing out partial pages at the beginning and end
of the range, whether beyond eof or not. The data beyond eof is already
expected to be all zeroes, though. Truncate the range passed to
iomap_zero_range().
As an alternative approach, we could also implicitly truncate the range
inside iomap_zero_range() instead of issuing a warning. Any thoughts?
Thanks,
Andreas
--
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index b81984def58e..d9a4309cd414 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1301,6 +1301,10 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from,
unsigned int length)
{
BUG_ON(current->journal_info);
+ if (from > inode->i_size)
+ return 0;
+ if (from + length > inode->i_size)
+ length = inode->i_size - from;
return iomap_zero_range(inode, from, length, NULL, &gfs2_iomap_ops,
NULL);
}
next reply other threads:[~2025-05-08 13:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-08 13:34 Andreas Gruenbacher [this message]
2025-05-08 14:17 ` [RFC] gfs2: Do not call iomap_zero_range beyond eof Christoph Hellwig
2025-05-08 14:30 ` Brian Foster
2025-05-08 15:04 ` Darrick J. Wong
2025-05-08 15:19 ` Brian Foster
2025-05-08 16:04 ` Darrick J. Wong
2025-05-08 16:34 ` Brian Foster
2025-05-08 16:36 ` Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250508133427.3799322-1-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=bfoster@redhat.com \
--cc=brauner@kernel.org \
--cc=gfs2@lists.linux.dev \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox