From: Darrick J. Wong <djwong@xxxxxxxxxx> Source kernel commit: fd7588fa6475771fe95f44011aea268c5d841da2 We're about to segment xfs_rtblock_t addresses, so we must create type-specific helpers to do rt extent rounding of file block offsets because the rtb helpers soon will not do the right thing there. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> --- libxfs/xfs_rtbitmap.h | 17 +++++++++++++---- repair/dinode.c | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h index 7be76490a31879..dc2b8beadfc331 100644 --- a/libxfs/xfs_rtbitmap.h +++ b/libxfs/xfs_rtbitmap.h @@ -135,13 +135,22 @@ xfs_rtb_roundup_rtx( return roundup_64(rtbno, mp->m_sb.sb_rextsize); } -/* Round this rtblock down to the nearest rt extent size. */ +/* Round this file block offset up to the nearest rt extent size. */ static inline xfs_rtblock_t -xfs_rtb_rounddown_rtx( +xfs_fileoff_roundup_rtx( struct xfs_mount *mp, - xfs_rtblock_t rtbno) + xfs_fileoff_t off) { - return rounddown_64(rtbno, mp->m_sb.sb_rextsize); + return roundup_64(off, mp->m_sb.sb_rextsize); +} + +/* Round this file block offset down to the nearest rt extent size. */ +static inline xfs_rtblock_t +xfs_fileoff_rounddown_rtx( + struct xfs_mount *mp, + xfs_fileoff_t off) +{ + return rounddown_64(off, mp->m_sb.sb_rextsize); } /* Convert an rt extent number to a file block offset in the rt bitmap file. */ diff --git a/repair/dinode.c b/repair/dinode.c index 2185214ac41bdf..56c7257d3766f1 100644 --- a/repair/dinode.c +++ b/repair/dinode.c @@ -197,7 +197,7 @@ process_rt_rec_dups( xfs_rtblock_t b; xfs_rtxnum_t ext; - for (b = xfs_rtb_rounddown_rtx(mp, irec->br_startblock); + for (b = irec->br_startblock; b < irec->br_startblock + irec->br_blockcount; b += mp->m_sb.sb_rextsize) { ext = xfs_rtb_to_rtx(mp, b); @@ -245,7 +245,7 @@ process_rt_rec_state( do_error( _("data fork in rt inode %" PRIu64 " found invalid rt extent %"PRIu64" state %d at rt block %"PRIu64"\n"), ino, ext, state, b); - b = xfs_rtb_roundup_rtx(mp, b); + b += mp->m_sb.sb_rextsize - mod; continue; }