Re: [PATCH v5 2/3] ext4: set EXT4_STATE_NO_EXPAND in ext4_evict_inode

From: Jan Kara

Date: Mon Jun 15 2026 - 12:30:34 EST


On Mon 15-06-26 19:53:16, Yun Zhou wrote:
> An inode being evicted will never need its extra isize expanded. Set
> EXT4_STATE_NO_EXPAND before ext4_mark_inode_dirty() in ext4_evict_inode()
> to make this explicit and prevent any unnecessary work in
> ext4_try_to_expand_extra_isize().
>
> This also provides defense-in-depth for the s_writepages_rwsem deadlock
> during mount-time orphan cleanup, ensuring the expand path is blocked
> for inodes under eviction regardless of how they are reached.
>
> Signed-off-by: Yun Zhou <yun.zhou@xxxxxxxxxxxxx>

Looks good. I'd move the setting somewhat earlier (just before
dquot_initialize()) so that it obviously covers all the inode dirtying that
can happen while deleting the inode. But otherwise feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

Honza

> ---
> fs/ext4/inode.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index be1e3eaa4f23..60c91c098fa0 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -264,6 +264,7 @@ void ext4_evict_inode(struct inode *inode)
> if (ext4_inode_is_fast_symlink(inode))
> memset(EXT4_I(inode)->i_data, 0, sizeof(EXT4_I(inode)->i_data));
> inode->i_size = 0;
> + ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND);
> err = ext4_mark_inode_dirty(handle, inode);
> if (err) {
> ext4_warning(inode->i_sb,
> --
> 2.43.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR