On Thu, Oct 12, 2023 at 06:59:54AM +0200, Christoph Hellwig wrote: > On Wed, Oct 11, 2023 at 11:02:50AM -0700, Darrick J. Wong wrote: > > Fix the problem by reducing maxlen by any misalignment with prod. While > > we're at it, split the assertions into two so that we can tell which > > value had the bad alignment. > > Yay, I always hate it when I trigger these compund asserts.. > > > maxlen = min(mp->m_sb.sb_rextents, i + maxlen) - i; > > + maxlen -= maxlen % prod; > > > maxlen = min(mp->m_sb.sb_rextents, bno + maxlen) - bno; > > + maxlen -= maxlen % prod; > > Not sure if that's bikeshedding, but this almost asks for a little > helper with a comment. How about: /* * Make sure we don't run off the end of the rt volume. Be careful that * adjusting maxlen downwards doesn't cause us to fail the alignment checks. */ static inline xfs_extlen_t xfs_rtallocate_clamp_len( struct xfs_mount *mp, xfs_rtblock_t startrtx, xfs_extlen_t rtxlen, xfs_extlen_t prod) { xfs_extlen_t ret; ret = min(mp->m_sb.sb_rextents, startrtx + rtxlen) - startrtx; return rounddown(ret, prod); } minlen = xfs_rtallocate_clamp_len(mp, i, maxlen, prod); and minlen = xfs_rtalloc_clamp_len(mp, bno, maxlen, prod); --D > Otherwise looks good: > > Reviewed-by: Christoph Hellwig <hch@xxxxxx>