Re: [PATCH v2 1/2] fs: push list presence check into inode_io_list_del()
From: Jan Kara
Date: Thu Oct 30 2025 - 09:54:37 EST
On Wed 29-10-25 14:14:27, Mateusz Guzik wrote:
> For consistency with sb routines.
>
> Signed-off-by: Mateusz Guzik <mjguzik@xxxxxxxxx>
Not sure if you've noticed but inode_io_list_del() is also called from
ext4_evict_inode() (for annoying reasons but that's besides this thread).
So there you have another list_empty() check to deduplicate. Plus ext4
actually uses list_empty_careful() for the unlocked check which kind of
makes sense because in theory these checks could race with someone removing
the inode from writeback lists.
Honza
> ---
>
> rebased
>
> fs/fs-writeback.c | 3 +++
> fs/inode.c | 4 +---
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index f784d8b09b04..5dccbe5fb09d 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -1349,6 +1349,9 @@ void inode_io_list_del(struct inode *inode)
> {
> struct bdi_writeback *wb;
>
> + if (list_empty(&inode->i_io_list))
> + return;
> +
> wb = inode_to_wb_and_lock_list(inode);
> spin_lock(&inode->i_lock);
>
> diff --git a/fs/inode.c b/fs/inode.c
> index 1396f79b2551..b5c2efebaa18 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -815,9 +815,7 @@ static void evict(struct inode *inode)
> BUG_ON(!(inode_state_read_once(inode) & I_FREEING));
> BUG_ON(!list_empty(&inode->i_lru));
>
> - if (!list_empty(&inode->i_io_list))
> - inode_io_list_del(inode);
> -
> + inode_io_list_del(inode);
> inode_sb_list_del(inode);
>
> spin_lock(&inode->i_lock);
> --
> 2.34.1
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR