Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Helen Koike <koike@igalia.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-dev@igalia.com,
	koike@igalia.com
Subject: [PATCH] ext4: skip i_extra_isize expansion during inode eviction
Date: Wed, 15 Jul 2026 14:52:25 -0300	[thread overview]
Message-ID: <20260715175253.2171303-1-koike@igalia.com> (raw)

__ext4_mark_inode_dirty may be called from the eviction/free path (via
ext4_truncate → ext4_ext_truncate → mark_inode_dirty), which may call
ext4_try_to_expand_extra_isize() that could create a new EA inode,
wasting work that will be immediately discarded.

Skip the expansion when the inode is transitioning to freed.

Signed-off-by: Helen Koike <koike@igalia.com>
---

Hello,

I saw this while investigating the syzbot issue (see the stack trace of
unlink "-> #0"):
   https://syzkaller.appspot.com/bug?extid=d91a6e2efb07bd3354e9

While the reported issue is fixed by:
  7f473f971382 ("ext4: lockdep: handle i_data_sem subclassing for special inodes")
I believe the call to ext4_try_to_expand_extra_isize() in the eviction
path doesn't make sense in the first place.

I understand this is not a major optimization, so not a high priority,
but sending it anyway in case anyone finds it useful.
---
 fs/ext4/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ce99807c5f5b..cea3405cd841 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -6603,7 +6603,8 @@ int __ext4_mark_inode_dirty(handle_t *handle, struct inode *inode,
 	if (err)
 		goto out;
 
-	if (EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize)
+	if (EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize &&
+	    !(inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE)))
 		ext4_try_to_expand_extra_isize(inode, sbi->s_want_extra_isize,
 					       iloc, handle);
 
-- 
2.54.0


             reply	other threads:[~2026-07-15 17:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 17:52 Helen Koike [this message]
2026-07-16 19:59 ` [PATCH] ext4: skip i_extra_isize expansion during inode eviction Andreas Dilger
2026-07-21 14:28 ` Theodore Tso

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=20260715175253.2171303-1-koike@igalia.com \
    --to=koike@igalia.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=kernel-dev@igalia.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox