Re: [PATCH v7 3/4] ext4: introduce ext4_put_ea_inode() for safe deferred iput

From: Zhou, Yun

Date: Mon Jun 22 2026 - 06:10:36 EST


Hi Honza,

On 6/18/26 02:42, Jan Kara wrote:

Allocating ext4_ea_iput_entry for dropping each inode is somewhat wasteful.
I want to suggest another scheme (somewhat more involved but more efficient
scheme):

1) Create a VFS helper bool iput_if_not_last(struct inode *inode) which
drops inode reference if it is not the last one (and returns true in that
case). Basically:

bool iput_if_not_last(struct inode *inode)
{
return atomic_add_unless(&inode->i_count, -1, 1);
}

This needs to be a separate patch as it should get vetting from VFS
maintainers.
After taking a closer look, it seems that this function doesn't need to be added to the VFS layer — at least not for now. For example, we could directly inline atomic_add_unless() into ext4_put_ea_inode():

void ext4_put_ea_inode(struct super_block *sb, struct inode *inode)
{
if (!inode)
return;
if (atomic_add_unless(&inode->i_count, -1, 1))
return;
llist_add(&EXT4_I(inode)->i_ea_iput_node,
&EXT4_SB(sb)->s_ea_inode_to_free);
schedule_delayed_work(&EXT4_SB(sb)->s_ea_inode_work, 1);
}

This way, we avoid submitting an isolated patch to the VFS layer that currently has only one user (ext4). If there is indeed a real need for it in the future, we can always submit a follow-up patch to refactor it.

What do you think?

BR,
Yun