From: "Darrick J. Wong" <djwong@kernel.org>
To: Andrey Albershteyn <aalbersh@redhat.com>
Cc: fsverity@lists.linux.dev, linux-xfs@vger.kernel.org,
ebiggers@kernel.org, linux-fsdevel@vger.kernel.org,
aalbersh@kernel.org, david@fromorbit.com, hch@lst.de
Subject: Re: [PATCH v2 3/22] iomap: introduce IOMAP_F_BEYOND_EOF
Date: Mon, 12 Jan 2026 14:18:53 -0800 [thread overview]
Message-ID: <20260112221853.GI15551@frogsfrogsfrogs> (raw)
In-Reply-To: <d5fc72ldfwyzbgiypzlhn5diiqyijxaicpa3w6obx4iismuko3@kttpcgqjy6i5>
On Mon, Jan 12, 2026 at 03:50:05PM +0100, Andrey Albershteyn wrote:
> Flag to indicate to iomap that read/write is happening beyond EOF and no
> isize checks/update is needed.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
> ---
> fs/iomap/buffered-io.c | 13 ++++++++-----
> fs/iomap/trace.h | 3 ++-
> include/linux/iomap.h | 5 +++++
> 3 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index e5c1ca440d..cc1cbf2a4c 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -533,7 +533,8 @@
(Does your diff program not set --show-c-function? That makes reviewing
harder because I have to search on the comment text to figure out which
function this is)
> return 0;
>
> /* zero post-eof blocks as the page may be mapped */
> - if (iomap_block_needs_zeroing(iter, pos)) {
> + if (iomap_block_needs_zeroing(iter, pos) &&
> + !(iomap->flags & IOMAP_F_BEYOND_EOF)) {
Hrm. The last test in iomap_block_needs_zeroing is if pos is at or
beyond EOF, and iomap_adjust_read_range takes great pains to reduce plen
so that poff/plen never cross EOF. I think the intent of that code is
to ensure that we always zero the post-EOF part of a folio when reading
it in from disk.
For verity I can see why you don't want to zero the merkle tree blocks
beyond EOF, but I think this code can expose unwritten junk in the
post-EOF part of the EOF block on disk.
Would it be more correct to do:
static inline bool
iomap_block_needs_zeroing(
const struct iomap_iter *iter,
struct folio *folio,
loff_t pos)
{
const struct iomap *srcmap = iomap_iter_srcmap(iter);
if (srcmap->type != IOMAP_MAPPED)
return true;
if (srcmap->flags & IOMAP_F_NEW);
return true;
/*
* Merkle tree exists in a separate folio beyond EOF, so
* only zero if this is the EOF folio.
*/
if (iomap->flags & IOMAP_F_BEYOND_EOF)
return folio_pos(folio) == i_size_read(iter->inode);
return pos >= i_size_read(iter->inode);
}
> folio_zero_range(folio, poff, plen);
> iomap_set_range_uptodate(folio, poff, plen);
> } else {
> @@ -1130,13 +1131,14 @@
> * unlock and release the folio.
> */
> old_size = iter->inode->i_size;
> - if (pos + written > old_size) {
> + if (pos + written > old_size &&
> + !(iter->flags & IOMAP_F_BEYOND_EOF)) {
> i_size_write(iter->inode, pos + written);
> iter->iomap.flags |= IOMAP_F_SIZE_CHANGED;
> }
> __iomap_put_folio(iter, write_ops, written, folio);
>
> - if (old_size < pos)
> + if (old_size < pos && !(iter->flags & IOMAP_F_BEYOND_EOF))
> pagecache_isize_extended(iter->inode, old_size, pos);
>
> cond_resched();
> @@ -1815,8 +1817,9 @@
>
> trace_iomap_writeback_folio(inode, pos, folio_size(folio));
>
> - if (!iomap_writeback_handle_eof(folio, inode, &end_pos))
> - return 0;
> + if (!(wpc->iomap.flags & IOMAP_F_BEYOND_EOF) &&
> + !iomap_writeback_handle_eof(folio, inode, &end_pos))
Hrm. I /think/ this might break post-eof zeroing on writeback if
BEYOND_EOF is set. For verity this isn't a problem because there's no
writeback, but it's a bit of a logic bomb if someone ever tries to set
BEYOND_EOF on a non-verity file.
--D
> + return 0;
> WARN_ON_ONCE(end_pos <= pos);
>
> if (i_blocks_per_folio(inode, folio) > 1) {
> diff --git a/fs/iomap/trace.h b/fs/iomap/trace.h
> index 532787277b..f1895f7ae5 100644
> --- a/fs/iomap/trace.h
> +++ b/fs/iomap/trace.h
> @@ -118,7 +118,8 @@
> { IOMAP_F_ATOMIC_BIO, "ATOMIC_BIO" }, \
> { IOMAP_F_PRIVATE, "PRIVATE" }, \
> { IOMAP_F_SIZE_CHANGED, "SIZE_CHANGED" }, \
> - { IOMAP_F_STALE, "STALE" }
> + { IOMAP_F_STALE, "STALE" }, \
> + { IOMAP_F_BEYOND_EOF, "BEYOND_EOF" }
>
>
> #define IOMAP_DIO_STRINGS \
> diff --git a/include/linux/iomap.h b/include/linux/iomap.h
> index 520e967cb5..7a7e31c499 100644
> --- a/include/linux/iomap.h
> +++ b/include/linux/iomap.h
> @@ -86,6 +86,11 @@
> #define IOMAP_F_PRIVATE (1U << 12)
>
> /*
> + * IO happens beyound inode EOF
s/beyound/beyond/
> + */
> +#define IOMAP_F_BEYOND_EOF (1U << 13)
> +
> +/*
> * Flags set by the core iomap code during operations:
> *
> * IOMAP_F_SIZE_CHANGED indicates to the iomap_end method that the file size
>
> --
> - Andrey
>
>
next prev parent reply other threads:[~2026-01-12 22:18 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 14:49 [PATCH v2 0/23] fs-verity support for XFS with post EOF merkle tree Andrey Albershteyn
2026-01-12 14:49 ` [PATCH v2 1/22] fsverity: report validation errors back to the filesystem Darrick J. Wong
2026-01-13 1:29 ` Darrick J. Wong
2026-01-13 8:09 ` Christoph Hellwig
2026-01-13 10:27 ` Andrey Albershteyn
2026-01-13 17:52 ` Darrick J. Wong
2026-01-12 14:49 ` [PATCH v2 2/22] fsverity: expose ensure_fsverity_info() Andrey Albershteyn
2026-01-12 22:05 ` Darrick J. Wong
2026-01-12 14:50 ` [PATCH v2 3/22] iomap: introduce IOMAP_F_BEYOND_EOF Andrey Albershteyn
2026-01-12 22:18 ` Darrick J. Wong [this message]
2026-01-12 22:31 ` Darrick J. Wong
2026-01-13 10:39 ` Andrey Albershteyn
2026-01-13 8:12 ` Christoph Hellwig
2026-01-13 10:50 ` Andrey Albershteyn
2026-01-13 16:22 ` Christoph Hellwig
2026-01-13 17:57 ` Darrick J. Wong
2026-01-16 21:52 ` Matthew Wilcox
2026-01-17 2:11 ` Darrick J. Wong
2026-01-12 14:50 ` [PATCH v2 4/22] iomap: allow iomap_file_buffered_write() take iocb without file Andrey Albershteyn
2026-01-12 22:22 ` Darrick J. Wong
2026-01-13 8:15 ` Christoph Hellwig
2026-01-13 10:53 ` Andrey Albershteyn
2026-01-13 16:43 ` Matthew Wilcox
2026-01-14 4:49 ` Matthew Wilcox
2026-01-14 6:41 ` Christoph Hellwig
2026-01-14 16:43 ` Darrick J. Wong
2026-01-12 14:50 ` [PATCH v2 5/22] iomap: integrate fs-verity verification into iomap's read path Andrey Albershteyn
2026-01-12 22:35 ` Darrick J. Wong
2026-01-13 11:16 ` Andrey Albershteyn
2026-01-13 16:23 ` Christoph Hellwig
2026-01-13 8:19 ` Christoph Hellwig
2026-01-12 14:50 ` [PATCH v2 6/22] xfs: add fs-verity ro-compat flag Andrey Albershteyn
2026-01-12 14:50 ` [PATCH v2 7/22] xfs: add inode on-disk VERITY flag Andrey Albershteyn
2026-01-12 14:50 ` [PATCH v2 8/22] xfs: initialize fs-verity on file open and cleanup on inode destruction Andrey Albershteyn
2026-01-12 14:50 ` [PATCH v2 9/22] xfs: don't allow to enable DAX on fs-verity sealed inode Andrey Albershteyn
2026-01-12 14:51 ` [PATCH v2 10/22] xfs: disable direct read path for fs-verity files Andrey Albershteyn
2026-01-13 8:20 ` Christoph Hellwig
2026-01-13 11:22 ` Andrey Albershteyn
2026-01-12 14:51 ` [PATCH v2 11/22] xfs: add verity info pointer to xfs inode Andrey Albershteyn
2026-01-12 22:39 ` Darrick J. Wong
2026-01-13 8:21 ` Christoph Hellwig
2026-01-13 18:02 ` Darrick J. Wong
2026-01-14 6:43 ` Christoph Hellwig
2026-01-12 14:51 ` [PATCH v2 12/22] xfs: introduce XFS_FSVERITY_CONSTRUCTION inode flag Andrey Albershteyn
2026-01-12 22:42 ` Darrick J. Wong
2026-01-13 11:24 ` Andrey Albershteyn
2026-01-12 14:51 ` [PATCH v2 13/22] xfs: introduce XFS_FSVERITY_REGION_START constant Andrey Albershteyn
2026-01-12 22:46 ` Darrick J. Wong
2026-01-13 12:23 ` Andrey Albershteyn
2026-01-13 18:06 ` Darrick J. Wong
2026-01-14 6:47 ` Christoph Hellwig
2026-01-14 7:59 ` Andrey Albershteyn
2026-01-14 16:50 ` Darrick J. Wong
2026-01-12 14:51 ` [PATCH v2 14/22] xfs: disable preallocations for fsverity Merkle tree writes Andrey Albershteyn
2026-01-12 22:49 ` Darrick J. Wong
2026-01-12 14:51 ` [PATCH v2 15/22] xfs: add writeback and iomap reading of Merkle tree pages Andrey Albershteyn
2026-01-12 22:51 ` Darrick J. Wong
2026-01-13 8:23 ` Christoph Hellwig
2026-01-13 12:31 ` Andrey Albershteyn
2026-01-12 14:51 ` [PATCH v2 16/22] xfs: add fs-verity support Andrey Albershteyn
2026-01-12 23:05 ` Darrick J. Wong
2026-01-13 18:32 ` Andrey Albershteyn
2026-01-14 16:40 ` Darrick J. Wong
2026-01-16 14:52 ` Andrey Albershteyn
2026-01-12 14:51 ` [PATCH v2 17/22] xfs: add fs-verity ioctls Andrey Albershteyn
2026-01-12 14:52 ` [PATCH v2 18/22] xfs: advertise fs-verity being available on filesystem Darrick J. Wong
2026-01-12 14:52 ` [PATCH v2 19/22] xfs: check and repair the verity inode flag state Darrick J. Wong
2026-01-12 14:52 ` [PATCH v2 20/22] xfs: report verity failures through the health system Darrick J. Wong
2026-01-12 14:52 ` [PATCH v2 21/22] xfs: add fsverity traces Andrey Albershteyn
2026-01-12 23:07 ` Darrick J. Wong
2026-01-12 14:52 ` [PATCH v2 22/22] xfs: enable ro-compat fs-verity flag Andrey Albershteyn
2026-01-13 16:36 ` [PATCH v2 0/23] fs-verity support for XFS with post EOF merkle tree Matthew Wilcox
2026-01-13 18:45 ` Andrey Albershteyn
2026-01-14 5:00 ` Matthew Wilcox
2026-01-14 6:15 ` Darrick J. Wong
2026-01-14 8:20 ` Andrey Albershteyn
2026-01-14 9:53 ` Andrey Albershteyn
2026-01-14 16:42 ` Darrick J. Wong
2026-01-19 6:33 ` fsverity metadata offset, was: " Christoph Hellwig
2026-01-19 19:32 ` Eric Biggers
2026-01-19 19:58 ` Darrick J. Wong
2026-01-20 7:32 ` Christoph Hellwig
2026-01-20 11:44 ` Andrey Albershteyn
2026-01-20 17:34 ` Darrick J. Wong
2026-01-21 15:03 ` Christoph Hellwig
2026-01-19 20:00 ` Matthew Wilcox
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=20260112221853.GI15551@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@kernel.org \
--cc=aalbersh@redhat.com \
--cc=david@fromorbit.com \
--cc=ebiggers@kernel.org \
--cc=fsverity@lists.linux.dev \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.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