Re: [PATCH] fs: add missing fences to I_NEW handling

From: Mateusz Guzik

Date: Mon Oct 06 2025 - 08:20:40 EST


On Mon, Oct 6, 2025 at 2:15 PM Jan Kara <jack@xxxxxxx> wrote:
>
> On Mon 06-10-25 01:15:26, Mateusz Guzik wrote:
> > diff --git a/include/linux/writeback.h b/include/linux/writeback.h
> > index 22dd4adc5667..e1e1231a6830 100644
> > --- a/include/linux/writeback.h
> > +++ b/include/linux/writeback.h
> > @@ -194,6 +194,10 @@ static inline void wait_on_inode(struct inode *inode)
> > {
> > wait_var_event(inode_state_wait_address(inode, __I_NEW),
> > !(READ_ONCE(inode->i_state) & I_NEW));
> > + /*
> > + * Pairs with routines clearing I_NEW.
> > + */
> > + smp_rmb();
>
> ... smp_load_acquire() instead if READ_ONCE? That would seem like a more
> "modern" way to fix this?
>

Now that the merge window flurry has died down I'll be posting an
updated i_state accessor patchset.

Then I would need to add inode_state_read_once_acquire() and
inode_state_clear_release() to keep up with this.

I figured I'll spare it for the time being, worst case can be added later.

That aside I have a wip patch to not require fences here and instead
take advantage of the i_lock held earlier, so I expect this to go away
anyway.