Linux EXT4 FS development
 help / color / mirror / Atom feed
From: "Petr Vaněk" <petr.vanek@e2b.dev>
To: "Theodore Ts'o" <tytso@mit.edu>,
	Andreas Dilger <adilger.kernel@dilger.ca>,
	Baokun Li <libaokun@linux.alibaba.com>, Jan Kara <jack@suse.cz>,
	Ojaswin Mujoo <ojaswin@linux.ibm.com>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	Zhang Yi <yi.zhang@huawei.com>
Cc: "Deepanshu Kartikey" <kartikey406@gmail.com>,
	"Petr Vaněk" <petr.vanek@e2b.dev>,
	linux-ext4@vger.kernel.org
Subject: [PATCH 0/3] ext4: fix data loss in inline data conversion of regular files
Date: Thu, 26 Nov 2026 21:12:52 +0100	[thread overview]
Message-ID: <20261126201258.1553196-1-petr.vanek@e2b.dev> (raw)

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


             reply	other threads:[~2026-11-26 20:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 20:12 Petr Vaněk [this message]
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

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=20261126201258.1553196-1-petr.vanek@e2b.dev \
    --to=petr.vanek@e2b.dev \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=kartikey406@gmail.com \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huawei.com \
    /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