On Tue, Apr 11, 2023 at 11:49:34AM -0700, Darrick J. Wong wrote: > @@ -226,10 +226,15 @@ xfs_iformat_data_fork( > > /* > * Initialize the extent count early, as the per-format routines may > - * depend on it. > + * depend on it. Use release semantics to set needextents /after/ we > + * set the format. This ensures that we can use acquire semantics on > + * needextents in xfs_need_iread_extents() and be guaranteed to see a > + * valid format value after that load. > */ > ip->i_df.if_format = dip->di_format; > ip->i_df.if_nextents = xfs_dfork_data_extents(dip); > + smp_store_release(&ip->i_df.if_needextents, > + ip->i_df.if_format == XFS_DINODE_FMT_BTREE ? 1 : 0); ip->i_df is memset to zero a little earlier (same for the attr fork), this only needs to be: if (ip->i_df.if_format == XFS_DINODE_FMT_BTREE) smp_store_release(&ip->i_df.if_needextents, 1);