@@ -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.
*/
@@ -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);
}
/*
@@ -1633,8 +1633,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);
@@ -28,6 +28,7 @@
#include "xfs_icache.h"
#include "xfs_log.h"
#include "xfs_rtalloc.h"
+#include "xfs_rtbitmap.h"
#include <linux/fsnotify.h>
/*
@@ -1236,8 +1237,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)