Re: [PATCH v2 09/10] fs: set I_FREEING instead of I_WILL_FREE in iput_final() prior to writeback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 9, 2025 at 11:14 AM Mateusz Guzik <mjguzik@xxxxxxxxx> wrote:
>
> This is in preparation for I_WILL_FREE flag removal.
>
> Signed-off-by: Mateusz Guzik <mjguzik@xxxxxxxxx>
> ---
>  fs/inode.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/inode.c b/fs/inode.c
> index 20f36d54348c..9c695339ec3e 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -1880,18 +1880,17 @@ static void iput_final(struct inode *inode)
>                 return;
>         }
>
> +       inode_state_add(inode, I_FREEING);
> +
>         if (!drop) {
> -               inode_state_add(inode, I_WILL_FREE);
>                 spin_unlock(&inode->i_lock);
>
>                 write_inode_now(inode, 1);
>
>                 spin_lock(&inode->i_lock);
> -               inode_state_del(inode, I_WILL_FREE);
>                 WARN_ON(inode_state_read(inode) & I_NEW);
>         }
>
> -       inode_state_add(inode, I_FREEING);
>         if (!list_empty(&inode->i_lru))
>                 inode_lru_list_del(inode);
>         spin_unlock(&inode->i_lock);
> --
> 2.43.0
>

With a closer look I think this is buggy. write_inode_now() makes
assumptions that I_FREEING implies removal from the io list, but does
not assert on it.

So I'm going to post an updated patch which moves this write down
evict() after removal from the io list, and only issue the write
conditionally based on the drop parameter.

On top of that write_inode_now() is going to make a bunch of asserts
about the inode being clean after the write if I_FREEING is set.

-- 
Mateusz Guzik <mjguzik gmail.com>





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux