Re: [PATCH 21/26] xfs: make the RT allocator rtgroup aware

Christoph Hellwig
2024-08-27T04:59:21Z

On Mon, Aug 26, 2024 at 02:56:37PM +1000, Dave Chinner wrote:
> > + if (xfs_has_rtgroups(ap->ip->i_mount)) {
> > + error = xfs_rtallocate_rtgs(ap->tp, bno_hint, raminlen, ralen,
> > + prod, ap->wasdel, initial_user_data,
> > + &ap->blkno, &ap->length);
> > + } else {
> > + error = xfs_rtallocate_rtg(ap->tp, 0, bno_hint, raminlen, ralen,
> > + prod, ap->wasdel, initial_user_data,
> > + &rtlocked, &ap->blkno, &ap->length);
> > + }
>
> The xfs_has_rtgroups() check is unnecessary. The iterator in
> xfs_rtallocate_rtgs() will do the right thing for the
> !xfs_has_rtgroups() case - it'll set start_rgno = 0 and break out
> after a single call to xfs_rtallocate_rtg() with rgno = 0.

The iterator itself does, but the start_rgno calculation does not.
But we can make that conditional, which shouldn't be too bad especially
if we merge xfs_rtallocate_rtgs into xfs_bmap_rtalloc.

> Another thing that probably should be done here is push all the
> constant value calculations a couple of functions down the stack to
> where they are used. Then we only need to pass two parameters down
> through the rg iterator here, not 11...

Well, not too much of that actually is constant.