Re: [RFC PATCH v4 6/8] xfs: correct the truncate blocksize of realtime inode

From: Christoph Hellwig
Date: Fri May 31 2024 - 09:36:22 EST


On Wed, May 29, 2024 at 05:52:04PM +0800, Zhang Yi wrote:
> + if (xfs_inode_has_bigrtalloc(ip))
> + first_unmap_block = xfs_rtb_roundup_rtx(mp, first_unmap_block);

Given that first_unmap_block is a xfs_fileoff_t and not a xfs_rtblock_t,
this looks a bit confusing. I'd suggest to just open code the
arithmetics in xfs_rtb_roundup_rtx. For future proofing my also
use xfs_inode_alloc_unitsize() as in the hunk below instead of hard
coding the rtextsize. I.e.:

first_unmap_block = XFS_B_TO_FSB(mp,
roundup_64(new_size, xfs_inode_alloc_unitsize(ip)));