[PATCH 1/2] fs: add iput_not_last()

Jan Kara jack at suse.cz
Thu Nov 6 09:43:52 UTC 2025


On Wed 05-11-25 22:20:24, Mateusz Guzik wrote:
> Signed-off-by: Mateusz Guzik <mjguzik at gmail.com>

I guess better than giving up the common might_sleep() annotation. Feel
free to add:

Reviewed-by: Jan Kara <jack at suse.cz>

One nit below:

> +/**
> + *	iput_not_last	- put an inode assuming this is not the last reference
> + *	@inode: inode to put
> + */
> +void iput_not_last(struct inode *inode)
> +{

Standard iput() silently does nothing for NULL inode. I'm undecided whether
it belongs here or not. It might be convenient for some error handling
paths but OTOH if you are confident you hold a reference then inode should
better not be NULL...

								Honza

> +	VFS_BUG_ON_INODE(atomic_read(&inode->i_count) < 2, inode);
> +
> +	WARN_ON(atomic_sub_return(1, &inode->i_count) == 0);
> +}
-- 
Jan Kara <jack at suse.com>
SUSE Labs, CR



More information about the Linux-security-module-archive mailing list