diff options
author | Darrick J. Wong <djwong@kernel.org> | 2022-08-17 15:59:30 -0700 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2022-11-09 19:07:54 -0800 |
commit | 15d265aafa2b50f03bae08a19ad0575706ad3ead (patch) | |
tree | 3c68924f1394e93478724eb17f354ba4c3210e73 | |
parent | 2ade145f4d2a7edefcc17c2162ec9626f41959d3 (diff) |
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>
-rw-r--r-- | fs/xfs/libxfs/xfs_rtbitmap.h | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_xchgrange.c | 4 |
4 files changed, 25 insertions, 9 deletions
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.h b/fs/xfs/libxfs/xfs_rtbitmap.h index 689f0a7a56ee..fbed9ae19c51 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.h +++ b/fs/xfs/libxfs/xfs_rtbitmap.h @@ -56,6 +56,24 @@ xfs_rtb_to_rtxt( return div_u64(rtbno, mp->m_sb.sb_rextsize); } +/* Round this rtblock up to the nearest rt extent size. */ +static inline xfs_rtblock_t +xfs_rtb_roundup_rtx( + struct xfs_mount *mp, + xfs_rtblock_t rtbno) +{ + return roundup_64(rtbno, mp->m_sb.sb_rextsize); +} + +/* Round this rtblock down to the nearest rt extent size. */ +static inline xfs_rtblock_t +xfs_rtb_rounddown_rtx( + struct xfs_mount *mp, + xfs_rtblock_t rtbno) +{ + return rounddown_64(rtbno, mp->m_sb.sb_rextsize); +} + /* * Functions for walking free space rtextents in the realtime bitmap. */ diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index a15ba7b47e0a..2fe95c9a15bd 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -683,7 +683,7 @@ xfs_can_free_eofblocks( */ end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) - end_fsb = roundup_64(end_fsb, mp->m_sb.sb_rextsize); + end_fsb = xfs_rtb_roundup_rtx(mp, end_fsb); last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); if (last_fsb <= end_fsb) return false; @@ -982,10 +982,8 @@ xfs_free_file_space( /* We can only free complete realtime extents. */ if (xfs_inode_has_bigrtextents(ip)) { - startoffset_fsb = roundup_64(startoffset_fsb, - mp->m_sb.sb_rextsize); - endoffset_fsb = rounddown_64(endoffset_fsb, - mp->m_sb.sb_rextsize); + startoffset_fsb = xfs_rtb_roundup_rtx(mp, startoffset_fsb); + endoffset_fsb = xfs_rtb_rounddown_rtx(mp, endoffset_fsb); } /* diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 1953a00755f4..b74ba5e51cf8 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1552,8 +1552,8 @@ xfs_rtfile_convert_unwritten( if (mp->m_sb.sb_rextsize == 1) return 0; - off = rounddown_64(XFS_B_TO_FSBT(mp, pos), mp->m_sb.sb_rextsize); - endoff = roundup_64(XFS_B_TO_FSB(mp, pos + len), mp->m_sb.sb_rextsize); + off = xfs_rtb_rounddown_rtx(mp, XFS_B_TO_FSBT(mp, pos)); + endoff = xfs_rtb_roundup_rtx(mp, XFS_B_TO_FSB(mp, pos + len)); trace_xfs_rtfile_convert_unwritten(ip, pos, len); diff --git a/fs/xfs/xfs_xchgrange.c b/fs/xfs/xfs_xchgrange.c index 5e5380582f53..1951fcfdb1d9 100644 --- a/fs/xfs/xfs_xchgrange.c +++ b/fs/xfs/xfs_xchgrange.c @@ -29,6 +29,7 @@ #include "xfs_icache.h" #include "xfs_log.h" #include "xfs_rtalloc.h" +#include "xfs_rtbitmap.h" /* Lock (and optionally join) two inodes for a file range exchange. */ void @@ -802,8 +803,7 @@ xfs_xchg_range( * offsets and length in @fxr are safe to round up. */ if (XFS_IS_REALTIME_INODE(ip2)) - req.blockcount = roundup_64(req.blockcount, - mp->m_sb.sb_rextsize); + req.blockcount = xfs_rtb_roundup_rtx(mp, req.blockcount); error = xfs_xchg_range_estimate(&req); if (error) |