ext4_restore_inline_data() recreates the system.data xattr with ext4_create_inline_data(), which marks the inode dirty and so sets its checksum, and only then copies the saved bytes into the raw inode with ext4_write_inline_data(). Unless something dirties the inode again before it is written out, the inode reaches the disk with a checksum that does not match its contents. Failed inline data conversions take this path, for example an mmap write to a small inline file on a full filesystem: mkfs.ext4 -O inline_data /dev/vdb 64M mount /dev/vdb /mnt xfs_io -f -c "pwrite -S 0x61 0 42" /mnt/small xfs_io -f -c "falloc 0 64m" /mnt/fill # ENOSPC, fs is full xfs_io -c "mmap -rw 0 42" -c "mwrite 0 1" /mnt/small # SIGBUS umount /mnt; mount /dev/vdb /mnt cat /mnt/small # EBADMSG The read after the remount fails with: [ 1.203967] EXT4-fs error (device vdb): ext4_lookup:1635: inode #4097: comm cat: iget: checksum invalid Mark the inode dirty again after ext4_write_inline_data(), so the checksum written to disk covers the restored data. The Fixes tag is based on code analysis: ext4_restore_inline_data() has called ext4_create_inline_data() before ext4_write_inline_data() since that commit. The failure reproduces on v5.19 and later; older kernels were not tested. Fixes: 3c47d54170b6 ("ext4: let add_dir_entry handle inline data properly") Cc: stable@vger.kernel.org Signed-off-by: Petr Vaněk --- This patch was developed with the help of an AI coding assistant (Claude Opus via OpenCode). It analysed the bug, wrote the fix and the changelog, and built the QEMU test setup; I reviewed the change and the test results. Tested with the reproducer above in QEMU (x86_64, KASAN and lockdep enabled) on 7.4-rc5 with and without the patch; e2fsck is clean after the patched run. Not tested: xfstests, other architectures. fs/ext4/inline.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index acdc65ce47960..360c06441c8f1 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1111,6 +1111,8 @@ static void ext4_restore_inline_data(handle_t *handle, struct inode *inode, } ext4_write_inline_data(inode, iloc, buf, 0, inline_size); ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); + /* Update the inode checksum to cover the restored data. */ + ext4_mark_inode_dirty(handle, inode); } struct buffer_head *ext4_inline_getblk(struct super_block *sb, -- 2.56.1