Re: [PATCH v3 04/14] xfs: make EOF allocation simpler

Dave Chinner
2024-08-07T00:00:49Z

On Tue, Aug 06, 2024 at 11:58:53AM -0700, Darrick J. Wong wrote:
> On Thu, Aug 01, 2024 at 04:30:47PM +0000, John Garry wrote:
> > @@ -3688,12 +3649,19 @@ xfs_bmap_btalloc_filestreams(
> > }
> >
> > args->minlen = xfs_bmap_select_minlen(ap, args, blen);
> > - if (ap->aeof)
> > - error = xfs_bmap_btalloc_at_eof(ap, args, blen, true);
> > + if (ap->aeof && ap->offset)
> > + error = xfs_bmap_btalloc_at_eof(ap, args);
> >
> > + /* This may be an aligned allocation attempt. */
> > if (!error && args->fsbno == NULLFSBLOCK)
> > error = xfs_alloc_vextent_near_bno(args, ap->blkno);
> >
> > + /* Attempt non-aligned allocation if we haven't already. */
> > + if (!error && args->fsbno == NULLFSBLOCK && args->alignment > 1) {
> > + args->alignment = 1;
> > + error = xfs_alloc_vextent_near_bno(args, ap->blkno);
>
> Oops, I just replied to the v2 thread instead of this.
>
> From
> https://lore.kernel.org/linux-xfs/20240621203556.GU3058325@frogsfrogsfrogs/
>
> Do we have to zero args->alignslop here?

No. It should always be zero here to begin with. It is the
responsibility of the allocation attempt that modifies
args->alignment and args->alignslop to reset them to original values
on allocation failure.

The only places we use alignslop are xfs_bmap_btalloc_at_eof() and
xfs_ialloc_ag_alloc(). They both zero it and reset args->alignment
on allocation failure before falling through to the next allocation
attempt.

-Dave.
--
Dave Chinner
david@fromorbit.com