diff mbox series

[14/35] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls

Message ID 20240215120907.1542854-15-cem@kernel.org (mailing list archive)
State Accepted, archived
Headers show
Series xfsprogs: libxfs-sync for 6.7 | expand

Commit Message

Carlos Maiolino Feb. 15, 2024, 12:08 p.m. UTC
From: "Darrick J. Wong" <djwong@kernel.org>

Source kernel commit: 055641248f649b52620a5fe8774bea253690e057

Convert these calls to use the helpers, and clean up all these places
where the same variable can have different units depending on where it
is in the function.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
---
 libxfs/xfs_bmap.c     |  8 ++------
 libxfs/xfs_rtbitmap.h | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index 6d7fa88f9..8fde0dc25 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c
@@ -4820,12 +4820,8 @@  xfs_bmap_del_extent_delay(
 	ASSERT(got->br_startoff <= del->br_startoff);
 	ASSERT(got_endoff >= del_endoff);
 
-	if (isrt) {
-		uint64_t	rtexts = del->br_blockcount;
-
-		do_div(rtexts, mp->m_sb.sb_rextsize);
-		xfs_mod_frextents(mp, rtexts);
-	}
+	if (isrt)
+		xfs_mod_frextents(mp, xfs_rtb_to_rtx(mp, del->br_blockcount));
 
 	/*
 	 * Update the inode delalloc counter now and wait to update the
diff --git a/libxfs/xfs_rtbitmap.h b/libxfs/xfs_rtbitmap.h
index 9df583083..ff901bf3d 100644
--- a/libxfs/xfs_rtbitmap.h
+++ b/libxfs/xfs_rtbitmap.h
@@ -70,6 +70,20 @@  xfs_rtb_to_rtxrem(
 	return div_u64_rem(rtbno, mp->m_sb.sb_rextsize, off);
 }
 
+/*
+ * Convert an rt block number into an rt extent number, rounding up to the next
+ * rt extent if the rt block is not aligned to an rt extent boundary.
+ */
+static inline xfs_rtxnum_t
+xfs_rtb_to_rtxup(
+	struct xfs_mount	*mp,
+	xfs_rtblock_t		rtbno)
+{
+	if (do_div(rtbno, mp->m_sb.sb_rextsize))
+		rtbno++;
+	return rtbno;
+}
+
 /*
  * Functions for walking free space rtextents in the realtime bitmap.
  */