Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] iomap: fixes for short copies and integrity bio sizes
@ 2026-10-29 10:34 Christian Brauner
  2026-10-29 10:34 ` [PATCH 1/2] iomap: don't mark unwritten parts of a folio uptodate Christian Brauner
  2026-10-29 10:34 ` [PATCH 2/2] iomap: keep large chunks from defeating the bio cap Christian Brauner
  0 siblings, 2 replies; 9+ messages in thread
From: Christian Brauner @ 2026-10-29 10:34 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Christoph Hellwig, Chris Mason, Josef Bacik, Matthew Wilcox,
	Zhang Yi, Joanne Koong, Darrick J. Wong, Brian Foster, linux-xfs,
	Christian Brauner (Amutable), stable

Two iomap fixes that came out of Josef's AI bug scans.

The first one is old. For a buffered write into a hole, an unwritten
extent or past EOF __iomap_write_begin() marks the zeroed blocks
uptodate before the copy from userspace. If the copy comes up short the
uncopied part of the write stays behind in an uptodate block:

        ftruncate(fd, 4096);
        pwrite(fd, p, 3000, 100);    /* 16 bytes at p, then PROT_NONE */
        pread(fd, buf, 4096, 0);

That returns 2984 bytes of whatever was in the page before. Willy
reported this in 2024 and Zhang Yi posted a fix but it never got merged.
I went with the same fix. Josef's version zeroed the partially written
blocks completely and only marked those uptodate. That works too but
it's a lot more code for the same result.

Willy suggested back then to drop the uptodate marking from
__iomap_write_begin() completely. I didn't do that. Blocks that were
read from disk are valid and keeping them uptodate means a retried short
copy doesn't have to read them again.

The second one is from v7.1. When the filesystem handles the integrity
metadata the bio size check wraps if a single chunk is larger than
max_integrity_io_size(). That limit is capped by the maximum segment
size, so it's 64 KiB on lpfc and qla2xxx, and XFS writeback of a large
preallocated file happily builds a single 300 MiB bio and overruns the
2 MiB integrity buffer.

Note that a single chunk above the limit still gets a bio of its own.
That's fine with 4k pages. But with 64k pages a folio can be 128 MiB
which needs 4 MiB of PI with 16 bytes of metadata per 512 byte interval.
That's not new though and needs a separate fix.

Both are tested in a VM. Without the first patch the short copy
reproducer leaks on XFS with 4k and 1k blocks and on ext4 with buffered
iomap, and an fsx-like checker with faulting user buffers fails within
a few hundred operations. With it both pass. The second patch was tested
with scsi_debug DIF/DIX patched to a 64 KiB maximum segment size.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Christian Brauner (1):
      iomap: don't mark unwritten parts of a folio uptodate

Josef Bacik (1):
      iomap: keep large chunks from defeating the bio cap

 fs/iomap/bio.c         | 2 +-
 fs/iomap/buffered-io.c | 3 ++-
 fs/iomap/internal.h    | 9 +++++++++
 fs/iomap/ioend.c       | 3 +--
 4 files changed, 13 insertions(+), 4 deletions(-)
---
base-commit: 65ba8f34ec886ec72b2c07ddc8cf3d815c32869d
change-id: 20261029-work-iomap-ai-fixes-5c962e384d74


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-30  1:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-29 10:34 [PATCH 0/2] iomap: fixes for short copies and integrity bio sizes Christian Brauner
2026-10-29 10:34 ` [PATCH 1/2] iomap: don't mark unwritten parts of a folio uptodate Christian Brauner
2026-10-29 12:12   ` Christoph Hellwig
2026-10-29 12:20     ` Christian Brauner
2026-10-29 12:21       ` Christoph Hellwig
2026-10-29 20:08   ` Joanne Koong
2026-10-30  1:07   ` Zhang Yi
2026-10-29 10:34 ` [PATCH 2/2] iomap: keep large chunks from defeating the bio cap Christian Brauner
2026-10-29 12:12   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox