Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH 0/3] ext4: fix data loss in inline data conversion of regular files
@ 2026-11-26 20:12 Petr Vaněk
  2026-11-26 20:12 ` [PATCH 1/3] ext4: drop KUnit checks tied to the inline conversion's metadata buffer Petr Vaněk
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Petr Vaněk @ 2026-11-26 20:12 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger, Baokun Li, Jan Kara,
	Ojaswin Mujoo, Ritesh Harjani (IBM), Zhang Yi
  Cc: Deepanshu Kartikey, Petr Vaněk, linux-ext4

Since commit ed9356a30e59 ("ext4: convert inline data to extents when
truncate exceeds inline size"), growing an inline file beyond its
inline capacity converts its data to a block.  The conversion copies
the data into the block device's buffer and journals
it as metadata, while subsequent file writes reach the same block through
the page cache.  A journal checkpoint can then overwrite those writes
with the stale copy, causing data loss.  Patch 2 describes the failure
and includes a reproducer.

Patch 2 fixes this by converting regular files through the page cache,
as buffered writes already do.  It changes only fs/ext4/inline.c, keeping
the fix separate from the KUnit changes for stable backports.

Patches 1 and 3 update the KUnit test for ext4_convert_inline_data().
Patch 1 removes checks of the metadata buffer that the fix no longer
uses, allowing the test to pass both before and after the fix.  Patch 3
adds checks for conversion through the page cache.

Testing:

  - The reproducer in patch 2 loses data on 7.4-rc4 and passes with the
    fix, in QEMU on x86_64 with KASAN and lockdep enabled.
  - A QEMU test program covers truncate, fallocate, mmap and
    full-filesystem cases on inline_data filesystems with several mount
    options.  All cases pass with the series, and e2fsck reports no
    errors.  The truncate cases pass on the parent of ed9356a30e59 and
    fail on that commit.
  - The ext4 KUnit suite passes after each patch on top of the ext4 dev
    branch.

I have not run xfstests or tested other architectures.

For stable, patch 2 applies to 6.18 and later.  Kernels with
fs/ext4/inline-test.c need patch 1.  Older stable kernels carrying
ed9356a30e59 (6.12, 6.6, 6.1, 5.15, 5.10) need adapted backports.

AI assistance: Claude Opus via OpenCode analysed the bug and wrote the
fix, KUnit test changes, changelogs and QEMU tests.  I reviewed the code
and tests, ran the tests myself and checked the results by hand.

Petr Vaněk (3):
  ext4: drop KUnit checks tied to the inline conversion's metadata
    buffer
  ext4: convert regular file inline data through the page cache
  ext4: test inline data conversion through the page cache

 fs/ext4/inline-test.c |  92 ++++++++++++++++++++++++--------
 fs/ext4/inline.c      | 118 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 187 insertions(+), 23 deletions(-)

-- 
2.56.1


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

end of thread, other threads:[~2026-11-26 20:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 20:12 [PATCH 0/3] ext4: fix data loss in inline data conversion of regular files Petr Vaněk
2026-11-26 20:12 ` [PATCH 1/3] ext4: drop KUnit checks tied to the inline conversion's metadata buffer Petr Vaněk
2026-11-26 20:12 ` [PATCH 2/3] ext4: convert regular file inline data through the page cache Petr Vaněk
2026-11-26 20:43   ` sashiko-bot
2026-11-26 20:12 ` [PATCH 3/3] ext4: test inline data conversion " Petr Vaněk
2026-11-26 20:43 ` [PATCH 0/3] ext4: fix data loss in inline data conversion of regular files sashiko-bot

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