summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-08-17 15:59:30 -0700
committerDarrick J. Wong <djwong@kernel.org>2022-10-14 14:17:07 -0700
commitbd7439c2e3d0a8779e4225c4fdf34ba93647d8b5 (patch)
treeb0ef85d739b96d8fea7f89d326f551ee054c3a03
parent7af9445c2ae2ca24cf7cc1a4a2c6b73e354fc6b2 (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.h18
-rw-r--r--fs/xfs/xfs_bmap_util.c8
-rw-r--r--fs/xfs/xfs_rtalloc.c4
-rw-r--r--fs/xfs/xfs_xchgrange.c4
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 ce2c0639150d..5e204f107f5a 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -685,7 +685,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;
@@ -984,10 +984,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)