Re: [PATCH 1/6] xfs: check rt bitmap file geometry more thoroughly

Christoph Hellwig
2023-11-28T14:04:26Z

> + /*
> + * Now that we've locked the rtbitmap, we can't race with growfsrt
> + * trying to expand the bitmap or change the size of the rt volume.
> + * Hence it is safe to compute and check the geometry values.
> + */
> + rtb->rextents = xfs_rtb_to_rtx(mp, mp->m_sb.sb_rblocks);
> + rtb->rextslog = rtb->rextents ? xfs_highbit32(rtb->rextents) : 0;
> + rtb->rbmblocks = xfs_rtbitmap_blockcount(mp, rtb->rextents);

All these will be 0 if mp->m_sb.sb_rblocks, and rtb is zeroed allocation
right above, so calculating the values seems a bit odd. Why not simply:

if (mp->m_sb.sb_rblocks) {
rtb->rextents = xfs_rtb_to_rtx(mp, mp->m_sb.sb_rblocks);
rtb->rextslog = xfs_highbit32(rtb->rextents);
rtb->rbmblocks = xfs_rtbitmap_blockcount(mp, rtb->rextents);
}

?

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>