]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: convert do_div calls to xfs_rtb_to_rtx helper calls
authorDarrick J. Wong <djwong@kernel.org>
Mon, 12 Feb 2024 14:22:20 +0000 (15:22 +0100)
committerCarlos Maiolino <cem@kernel.org>
Thu, 15 Feb 2024 11:56:43 +0000 (12:56 +0100)
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
libxfs/xfs_rtbitmap.h

index 6d7fa88f94e03f356c2fae1bf61e199082d92a42..8fde0dc256f0179cc1213c4a6ce6318efb1c224d 100644 (file)
@@ -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
index 9df583083407b2f08f81e4a7518212cf6c79eca5..ff901bf3d1ee51f5e60910e15f683e998177d2aa 100644 (file)
@@ -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.
  */