Re: [PATCH v11 1/5] fs: add iput_if_not_last() helper
From: Christian Brauner
Date: Tue Jun 30 2026 - 04:56:23 EST
> Add a helper that drops an inode reference only if the caller does not
> hold the last one. Returns true if the reference was dropped, false
> otherwise.
>
> This is useful for filesystems that need to release inode references
> in contexts where triggering final iput (and thus eviction) would be
> unsafe due to lock ordering constraints. The caller can check the
> return value and defer the final iput to a safe context.
>
> Unlike iput_not_last() which BUG_ON's if called with the last ref,
> this variant is designed to be called speculatively.
>
> Signed-off-by: Yun Zhou <yun.zhou@xxxxxxxxxxxxx>
> Suggested-by: Jan Kara <jack@xxxxxxx>
> Reviewed-by: Jan Kara <jack@xxxxxxx>
Reviewed-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
--
Christian Brauner <brauner@xxxxxxxxxx>