[PATCH v4 0/5] ext4: fix inline data conversion races

From: Arbab Haider

Date: Thu Nov 26 2026 - 02:08:15 EST


This series addresses ext4 inline-data conversion races. Patch 1 fixes
the KUnit inode fixture so it passes on the base. Patch 2 fixes the
delayed-allocation handoff to writeback, carries the stable tags, and
can be applied independently. Patch 3 keeps synchronous conversion
state visible and serializes callers that inspect it. Patches 4 and 5
cover boot-loader swap and inode migration, respectively.

Booted each cumulative patch in QEMU x86-64 with KASAN, UBSAN and
lockdep. All five source trees passed all 22 ext4 KUnit suites. The
fixture-only tree also verifies that the two inode test failures on
the original base are fixed independently of the runtime patches.

The complete series also passed 555 ext4 KUnit tests in an arm64 QEMU
guest with lockdep and DEBUG_ATOMIC_SLEEP enabled. LKMM models of the
locked writeback handoff and rollback observation both excluded the
invalid state.
The arm64 guest also passed persistence and truncate checks on a 1 KiB
journaled filesystem and a 4 KiB filesystem without a journal.

The full series passed inline-to-block conversion, remount and data
comparison, and truncate-to-zero checks with delalloc, nodelalloc,
no journal, data journaling, 1 KiB blocks, bigalloc, fast commit and
indirect mappings. The indirect-mapping run also checked sparse reads,
SEEK_DATA/SEEK_HOLE, FIEMAP and direct reads. The boot-loader swap fix
rejected an inline file and completed a swap round trip on a disposable
image.
e2fsck -fn passed on all test images. Sashiko --no-ai passed patch
extraction and application.

Changes since v3:
- Rebase onto 4dce97c6c265 and split the change into five patches.
- Fix the nonatomic buffer lookup stub in the inode KUnit fixture.
- Publish the delayed-allocation handoff under xattr_sem and check it
under the same write lock used to remove inline data. Return -EIO on
an incomplete handoff and propagate inline removal and journal errors.
- Finish the delayed-allocation handoff on truncate-to-zero and on a
failed write at size zero. Extend the inline KUnit coverage.
- Keep MAY_INLINE_DATA set through synchronous conversion and serialize
callers that inspect inline state, preserving sparse-file readahead.
- Serialize boot-loader swap and inode migration against conversion.

Link: https://lore.kernel.org/linux-ext4/20261123172856.100887-2-arbabhaider649@xxxxxxxxx/

Arbab Haider (5):
ext4: stub the nonatomic buffer lookup in inode KUnit tests
ext4: fix delayed-allocation inline data conversion races
ext4: keep EXT4_STATE_MAY_INLINE_DATA set during inline conversion
ext4: re-check inline data under filemap_invalidate_lock in
swap_inode_boot_loader
ext4: serialize inode migration against concurrent inline data
conversion

fs/ext4/file.c | 73 ++++++++++++++++++++------
fs/ext4/inline-test.c | 17 +++++-
fs/ext4/inline.c | 118 +++++++++++++++++++++++++++++++++---------
fs/ext4/inode-test.c | 2 +
fs/ext4/inode.c | 71 ++++++++++++++++++-------
fs/ext4/ioctl.c | 4 ++
fs/ext4/migrate.c | 33 ++++++++----
fs/ext4/readpage.c | 15 ++++--
8 files changed, 260 insertions(+), 73 deletions(-)


base-commit: 4dce97c6c265544342e716e62fd24bbb232590c5
--
2.53.0