Re: [PATCH 09/43] xfs: generalize the freespace and reserved blocks handling

Christoph Hellwig
2024-12-13T05:11:31Z

On Thu, Dec 12, 2024 at 01:37:18PM -0800, Darrick J. Wong wrote:
> > mp->m_sb.sb_frextents =
> > - percpu_counter_sum_positive(&mp->m_frextents);
> > + xfs_sum_freecounter(mp, XC_FREE_RTEXTENTS);
>
> Curious. xfs_sum_freecounter returns percpu_counter_sum, not its
> _positive variant. This seems like a bug? Or at least an omitted
> max(0LL, ...) call?

Good question. This code is pretty old and it's probably time to do
a full audit of the _positive thingies, including checking if the
existing callers make sense and what the right levels of abstraction
are.

> > @@ -1297,8 +1314,7 @@ xfs_dec_freecounter(
> > * problems (i.e. transaction abort, pagecache discards, etc.) than
> > * slightly premature -ENOSPC.
> > */
> > - if (has_resv_pool)
> > - set_aside = xfs_fdblocks_unavailable(mp);
> > + set_aside = xfs_freecounter_unavailable(mp, ctr);
>
> Nit: I think you can get rid of the set_aside = 0; above?

Yes.