Re: [PATCH v7 03/14] fs: provide accessors for ->i_state

Jan Kara
2025-10-20T09:43:39Z

On Fri 10-10-25 17:51:06, Mateusz Guzik wrote:
> On Fri, Oct 10, 2025 at 4:44 PM Jan Kara <jack@suse.cz> wrote:
> >
> > On Thu 09-10-25 09:59:17, Mateusz Guzik wrote:
> > > +static inline void inode_state_set_raw(struct inode *inode,
> > > + enum inode_state_flags_enum flags)
> > > +{
> > > + WRITE_ONCE(inode->i_state, inode->i_state | flags);
> > > +}
> >
> > I think this shouldn't really exist as it is dangerous to use and if we
> > deal with XFS, nobody will actually need this function.
> >
>
> That's not strictly true, unless you mean code outside of fs/inode.c
>
> First, something is still needed to clear out the state in
> inode_init_always_gfp().
>
> Afterwards there are few spots which further modify it without the
> spinlock held (for example see insert_inode_locked4()).
>
> My take on the situation is that the current I_NEW et al handling is
> crap and the inode hash api is also crap.
>
> For starters freshly allocated inodes should not be starting with 0,
> but with I_NEW.
>
> I can agree after the dust settles there should be no _raw thing for
> filesystems to use, but getting there is beyond the scope of this
> patchset.

OK, then we are on the same page wrt the final goal. I can bear the raw
variants in the tree for some time if that makes the whole transition
easier.

Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR