Re: [PATCH v3] fs: push list presence check into inode_io_list_del()

From: Jan Kara

Date: Tue Nov 04 2025 - 07:08:57 EST


On Tue 04-11-25 00:09:11, Mateusz Guzik wrote:
> For consistency with sb routines.
>
> ext4 is the only consumer outside of evict(). Damage-controlling it is
> outside of the scope of this cleanup.
>
> Signed-off-by: Mateusz Guzik <mjguzik@xxxxxxxxx>

Thanks. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

One note below:

> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index f784d8b09b04..e2eed66aabf8 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -1349,6 +1349,13 @@ void inode_io_list_del(struct inode *inode)
> {
> struct bdi_writeback *wb;
>
> + /*
> + * FIXME: ext4 can call here from ext4_evict_inode() after evict() already
> + * unlinked the inode.
> + */

This is in fact due to a possible race between __mark_inode_dirty() called
from ending page writeback (which is perfectly legal for a filesystem to
do) and iput_final() + evict(). See bc12ac98ea2e ("ext4: silence the
warning when evicting inode with dioread_nolock") for details. So proper
solution should be in the generic code... E.g. checking emptiness of
i_io_list under i_lock should be enough to close the race but it's a bit
tricky to avoid the unnecessary lock roundtrip for clean inodes.

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR