Re: [PATCH v2 10/13] xfs: Unmap blocks according to forcealign

Dave Chinner
2024-07-09T09:57:26Z

On Sat, Jul 06, 2024 at 09:58:58AM +0200, Christoph Hellwig wrote:
>
> > + if (isforcealign) {
> > + off = ip->i_extsize - mod;
> > + } else {
> > + ASSERT(isrt);
> > + off = mp->m_sb.sb_rextsize - mod;
> > + }
>
> And we'll really need proper helpers so that we don't have to
> open code the i_extsize vs sb_rextsize logic all over.

We already have that: xfs_inode_alloc_unitsize().

Have the code get that value, then do all the alignment based on
whether it is allocation unit size > mp->m_sb.sb_blocksize. Then all
the calculations are generic and not dependent on forcealign or rt,
but on whether the inode requires multi-block contiguous extent
alignment....

i.e.
alloc_size = xfs_inode_alloc_unitsize(ip);
if (alloc_size > mp->m_sb.sb_blocksize) {
/* do aligned allocation setup stuff */
.....
}
....

No code should be doing "if (forcealign) ... else if (realtime) ..."
branching for alignment purposes. All the code should all be
generic based on the value xfs_inode_alloc_unitsize() returns.

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