Skip to content

Commit 5f57f73

Browse files
author
Darrick J. Wong
committed
xfs: create rt extent rounding helpers for realtime extent blocks
Create a pair of functions to round rtblock numbers up or down to the nearest rt extent. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 0556412 commit 5f57f73

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

fs/xfs/libxfs/xfs_rtbitmap.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ xfs_rtb_to_rtxup(
8484
return rtbno;
8585
}
8686

87+
/* Round this rtblock up to the nearest rt extent size. */
88+
static inline xfs_rtblock_t
89+
xfs_rtb_roundup_rtx(
90+
struct xfs_mount *mp,
91+
xfs_rtblock_t rtbno)
92+
{
93+
return roundup_64(rtbno, mp->m_sb.sb_rextsize);
94+
}
95+
96+
/* Round this rtblock down to the nearest rt extent size. */
97+
static inline xfs_rtblock_t
98+
xfs_rtb_rounddown_rtx(
99+
struct xfs_mount *mp,
100+
xfs_rtblock_t rtbno)
101+
{
102+
return rounddown_64(rtbno, mp->m_sb.sb_rextsize);
103+
}
104+
87105
/*
88106
* Functions for walking free space rtextents in the realtime bitmap.
89107
*/

fs/xfs/xfs_bmap_util.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ xfs_can_free_eofblocks(
684684
*/
685685
end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));
686686
if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1)
687-
end_fsb = roundup_64(end_fsb, mp->m_sb.sb_rextsize);
687+
end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb);
688688
last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
689689
if (last_fsb <= end_fsb)
690690
return false;
@@ -983,10 +983,8 @@ xfs_free_file_space(
983983

984984
/* We can only free complete realtime extents. */
985985
if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) {
986-
startoffset_fsb = roundup_64(startoffset_fsb,
987-
mp->m_sb.sb_rextsize);
988-
endoffset_fsb = rounddown_64(endoffset_fsb,
989-
mp->m_sb.sb_rextsize);
986+
startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb);
987+
endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb);
990988
}
991989

992990
/*

0 commit comments

Comments
 (0)