From: sashiko-bot@kernel.org
To: "Arbab Haider" <arbabhaider649@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH v2] ext4: avoid inline data conversion race when !EXT4_STATE_MAY_INLINE_DATA
Date: Mon, 23 Nov 2026 08:12:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-228890@kernel.org> (raw)
In-Reply-To: <20261123074825.63294-2-arbabhaider649@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ext4: spurious -EIO in ext4_convert_inline_data() after
truncate to zero
--
commit 9ccbfe6796f4c788a0b995f876e6cdb2091e3037
Author: Arbab Haider <arbabhaider649@gmail.com>
ext4: avoid inline data conversion race when !EXT4_STATE_MAY_INLINE_DATA
This commit replaces filemap_flush() with filemap_write_and_wait() in
ext4_convert_inline_data() when EXT4_STATE_MAY_INLINE_DATA is cleared,
returns -EIO if inline data remains after writeback, and rechecks
EXT4_STATE_MAY_INLINE_DATA after acquiring xattr_sem.
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index 2e14ee9b4241b..1faf277a22908 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -1997,6 +1997,7 @@ int ext4_convert_inline_data(struct inode *inode)
> handle_t *handle;
> struct ext4_iloc iloc;
>
> +retry:
> if (!ext4_has_inline_data(inode)) {
> ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
> return 0;
> @@ -2004,14 +2005,21 @@ int ext4_convert_inline_data(struct inode *inode)
> /*
> * Inode has inline data but EXT4_STATE_MAY_INLINE_DATA is
> * cleared. This means we are in the middle of moving of
> - * inline data to delay allocated block. Just force writeout
> - * here to finish conversion.
> + * inline data to delay allocated block. Force synchronous
> + * writeout here to finish conversion.
> */
> - error = filemap_flush(inode->i_mapping);
> + error = filemap_write_and_wait(inode->i_mapping);
> if (error)
> return error;
> if (!ext4_has_inline_data(inode))
> return 0;
> + /*
> + * Writeback did not clear inline data (e.g. filesystem is in
> + * emergency state). Do not proceed to
> + * ext4_convert_inline_data_nolock(), which would read stale
> + * on-disk inline data or race with writeback.
> + */
> + return -EIO;
> }
[Severity: High]
Can ext4_convert_inline_data() fail with a spurious -EIO after an
inline-data inode is truncated to 0 before writeback runs?
When a delayed-allocation write exceeds inline capacity,
ext4_da_convert_inline_data_to_extent() copies the data into folio 0,
marks it dirty, and clears EXT4_STATE_MAY_INLINE_DATA while leaving
EXT4_INODE_INLINE_DATA set until ext4_do_writepages() destroys the inline
data. If the file is truncated to 0 before writeback runs,
truncate_pagecache() drops dirty folio 0 and ext4_inline_data_truncate()
removes the delayed extent, but leaves EXT4_INODE_INLINE_DATA set and
EXT4_STATE_MAY_INLINE_DATA cleared.
Because inode->i_mapping no longer has dirty pages,
filemap_write_and_wait() returns 0 without calling ext4_destroy_inline_data(),
so ext4_has_inline_data(inode) remains true. Later calls to
ext4_convert_inline_data() (such as fallocate(), an extending truncate, or
ext4_page_mkwrite()) then fail with -EIO, or raise SIGBUS on shared mmap
write faults.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123074825.63294-2-arbabhaider649@gmail.com?part=1
prev parent reply other threads:[~2026-11-23 8:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 7:48 [PATCH v2] ext4: avoid inline data conversion race when !EXT4_STATE_MAY_INLINE_DATA Arbab Haider
2026-11-23 8:12 ` sashiko-bot [this message]
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=sashiko-outbox-228890@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arbabhaider649@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.