All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, osandov@osandov.com, hch@lst.de
Subject: [PATCH 5/7] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls
Date: Wed, 11 Oct 2023 11:05:42 -0700	[thread overview]
Message-ID: <169704721255.1773611.7719978115841778913.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <169704721170.1773611.12311239321983752854.stgit@frogsfrogsfrogs>

From: Darrick J. Wong <djwong@kernel.org>

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>
---
 fs/xfs/libxfs/xfs_bmap.c |    8 ++------
 fs/xfs/scrub/rtbitmap.c  |   14 +++++---------
 fs/xfs/xfs_bmap_util.c   |   10 ++++------
 fs/xfs/xfs_fsmap.c       |    8 ++++----
 fs/xfs/xfs_rtalloc.c     |    3 +--
 5 files changed, 16 insertions(+), 27 deletions(-)


diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 463174af94333..d322fd5116179 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -4883,12 +4883,8 @@ xfs_bmap_del_extent_delay(
 	ASSERT(got->br_startoff <= del->br_startoff);
 	ASSERT(got_endoff >= del_endoff);
 
-	if (isrt) {
-		uint64_t rtexts = XFS_FSB_TO_B(mp, 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_rtxt(mp, del->br_blockcount));
 
 	/*
 	 * Update the inode delalloc counter now and wait to update the
diff --git a/fs/xfs/scrub/rtbitmap.c b/fs/xfs/scrub/rtbitmap.c
index 01bc5119d612c..a785fb5f317dd 100644
--- a/fs/xfs/scrub/rtbitmap.c
+++ b/fs/xfs/scrub/rtbitmap.c
@@ -140,26 +140,22 @@ xchk_rtbitmap(
 void
 xchk_xref_is_used_rt_space(
 	struct xfs_scrub	*sc,
-	xfs_rtblock_t		fsbno,
+	xfs_rtblock_t		rtbno,
 	xfs_extlen_t		len)
 {
 	xfs_rtxnum_t		startext;
 	xfs_rtxnum_t		endext;
-	xfs_rtxlen_t		extcount;
 	bool			is_free;
 	int			error;
 
 	if (xchk_skip_xref(sc->sm))
 		return;
 
-	startext = fsbno;
-	endext = fsbno + len - 1;
-	do_div(startext, sc->mp->m_sb.sb_rextsize);
-	do_div(endext, sc->mp->m_sb.sb_rextsize);
-	extcount = endext - startext + 1;
+	startext = xfs_rtb_to_rtxt(sc->mp, rtbno);
+	endext = xfs_rtb_to_rtxt(sc->mp, rtbno + len - 1);
 	xfs_ilock(sc->mp->m_rbmip, XFS_ILOCK_SHARED | XFS_ILOCK_RTBITMAP);
-	error = xfs_rtalloc_extent_is_free(sc->mp, sc->tp, startext, extcount,
-			&is_free);
+	error = xfs_rtalloc_extent_is_free(sc->mp, sc->tp, startext,
+			endext - startext + 1, &is_free);
 	if (!xchk_should_check_xref(sc, &error, NULL))
 		goto out_unlock;
 	if (is_free)
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index c246f25aaad55..8f1e16e49dab2 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -157,14 +157,12 @@ xfs_bmap_rtalloc(
 	 * Realtime allocation, done through xfs_rtallocate_extent.
 	 */
 	if (ignore_locality)
-		ap->blkno = 0;
+		rtx = 0;
 	else
-		do_div(ap->blkno, mp->m_sb.sb_rextsize);
-	rtx = ap->blkno;
-	ap->length = ralen;
+		rtx = xfs_rtb_to_rtxt(mp, ap->blkno);
 	raminlen = max_t(xfs_rtxlen_t, 1, xfs_extlen_to_rtxlen(mp, minlen));
-	error = xfs_rtallocate_extent(ap->tp, ap->blkno, raminlen, ap->length,
-			&ralen, ap->wasdel, prod, &rtx);
+	error = xfs_rtallocate_extent(ap->tp, rtx, raminlen, ralen, &ralen,
+			ap->wasdel, prod, &rtx);
 	if (error)
 		return error;
 
diff --git a/fs/xfs/xfs_fsmap.c b/fs/xfs/xfs_fsmap.c
index 1a187bc9da3de..32aefaf7d6684 100644
--- a/fs/xfs/xfs_fsmap.c
+++ b/fs/xfs/xfs_fsmap.c
@@ -512,6 +512,7 @@ xfs_getfsmap_rtdev_rtbitmap(
 	xfs_rtblock_t			start_rtb;
 	xfs_rtblock_t			end_rtb;
 	uint64_t			eofs;
+	xfs_extlen_t			mod;
 	int				error;
 
 	eofs = XFS_FSB_TO_BB(mp, xfs_rtx_to_rtb(mp, mp->m_sb.sb_rextents));
@@ -539,10 +540,9 @@ xfs_getfsmap_rtdev_rtbitmap(
 	 * Set up query parameters to return free rtextents covering the range
 	 * we want.
 	 */
-	alow.ar_startext = start_rtb;
-	ahigh.ar_startext = end_rtb;
-	do_div(alow.ar_startext, mp->m_sb.sb_rextsize);
-	if (do_div(ahigh.ar_startext, mp->m_sb.sb_rextsize))
+	alow.ar_startext = xfs_rtb_to_rtxt(mp, start_rtb);
+	ahigh.ar_startext = xfs_rtb_to_rtx(mp, end_rtb, &mod);
+	if (mod)
 		ahigh.ar_startext++;
 	error = xfs_rtalloc_query_range(mp, tp, &alow, &ahigh,
 			xfs_getfsmap_rtdev_rtbitmap_helper, info);
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index d3a5112f21156..8db8f957a683b 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1056,8 +1056,7 @@ xfs_growfs_rt(
 		nrblocks_step = (bmbno + 1) * NBBY * nsbp->sb_blocksize *
 				nsbp->sb_rextsize;
 		nsbp->sb_rblocks = min(nrblocks, nrblocks_step);
-		nsbp->sb_rextents = nsbp->sb_rblocks;
-		do_div(nsbp->sb_rextents, nsbp->sb_rextsize);
+		nsbp->sb_rextents = xfs_rtb_to_rtxt(nmp, nsbp->sb_rblocks);
 		ASSERT(nsbp->sb_rextents != 0);
 		nsbp->sb_rextslog = xfs_highbit32(nsbp->sb_rextents);
 		nrsumlevels = nmp->m_rsumlevels = nsbp->sb_rextslog + 1;


  parent reply	other threads:[~2023-10-11 18:05 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-11 17:57 [PATCHBOMB RFC]: xfs: realtime units cleanups Darrick J. Wong
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/3] xfs: minor bugfixes for rt stuff Darrick J. Wong
2023-10-11 18:02   ` [PATCH 1/3] xfs: bump max fsgeom struct version Darrick J. Wong
2023-10-12  4:51     ` Christoph Hellwig
2023-10-12 17:34       ` Darrick J. Wong
2023-10-11 18:02   ` [PATCH 2/3] xfs: prevent rt growfs when quota is enabled Darrick J. Wong
2023-10-12  4:51     ` Christoph Hellwig
2023-10-11 18:02   ` [PATCH 3/3] xfs: rt stubs should return negative errnos when rt disabled Darrick J. Wong
2023-10-12  4:52     ` Christoph Hellwig
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/7] xfs: clean up realtime type usage Darrick J. Wong
2023-10-11 18:02   ` [PATCH 1/7] xfs: make sure maxlen is still congruent with prod when rounding down Darrick J. Wong
2023-10-12  4:59     ` Christoph Hellwig
2023-10-12 17:31       ` Darrick J. Wong
2023-10-13  4:22         ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 2/7] xfs: move the xfs_rtbitmap.c declarations to xfs_rtbitmap.h Darrick J. Wong
2023-10-12  6:33     ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 3/7] xfs: convert xfs_extlen_t to xfs_rtxlen_t in the rt allocator Darrick J. Wong
2023-10-12  5:00     ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 4/7] xfs: convert rt bitmap/summary block numbers to xfs_fileoff_t Darrick J. Wong
2023-10-12  5:01     ` Christoph Hellwig
2023-10-11 18:03   ` [PATCH 5/7] xfs: convert rt bitmap extent lengths to xfs_rtbxlen_t Darrick J. Wong
2023-10-12  5:01     ` Christoph Hellwig
2023-10-11 18:04   ` [PATCH 6/7] xfs: rename xfs_verify_rtext to xfs_verify_rtbext Darrick J. Wong
2023-10-12  5:02     ` Christoph Hellwig
2023-10-11 18:04   ` [PATCH 7/7] xfs: convert rt extent numbers to xfs_rtxnum_t Darrick J. Wong
2023-10-12  5:03     ` Christoph Hellwig
2023-10-12  5:05   ` [PATCHSET RFC v1.0 0/7] xfs: clean up realtime type usage Christoph Hellwig
2023-10-12 22:30     ` Darrick J. Wong
2023-10-13  4:24       ` Christoph Hellwig
2023-10-17  0:48         ` Darrick J. Wong
2023-10-17  4:05           ` Christoph Hellwig
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2023-10-11 18:04   ` [PATCH 1/7] xfs: create a helper to convert rtextents to rtblocks Darrick J. Wong
2023-10-12  5:10     ` Christoph Hellwig
2023-10-11 18:04   ` [PATCH 2/7] xfs: create a helper to compute leftovers of realtime extents Darrick J. Wong
2023-10-12  5:11     ` Christoph Hellwig
2023-10-12 17:40       ` Darrick J. Wong
2023-10-11 18:05   ` [PATCH 3/7] " Darrick J. Wong
2023-10-12  6:34     ` Christoph Hellwig
2023-10-11 18:05   ` [PATCH 4/7] xfs: create helpers to convert rt block numbers to rt extent numbers Darrick J. Wong
2023-10-12  5:17     ` Christoph Hellwig
2023-10-12 17:58       ` Darrick J. Wong
2023-10-13  4:25         ` Christoph Hellwig
2023-10-11 18:05   ` Darrick J. Wong [this message]
2023-10-12  5:22     ` [PATCH 5/7] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls Christoph Hellwig
2023-10-12 18:10       ` Darrick J. Wong
2023-10-11 18:05   ` [PATCH 6/7] xfs: create rt extent rounding helpers for realtime extent blocks Darrick J. Wong
2023-10-12  5:22     ` Christoph Hellwig
2023-10-11 18:06   ` [PATCH 7/7] xfs: use shifting and masking when converting rt extents, if possible Darrick J. Wong
2023-10-12  5:25     ` Christoph Hellwig
2023-10-12 18:19       ` Darrick J. Wong
2023-10-16 17:19         ` Omar Sandoval
2023-10-17  0:51           ` Darrick J. Wong
2023-10-11 18:01 ` [PATCHSET RFC v1.0 0/8] xfs: refactor rtbitmap/summary macros Darrick J. Wong
2023-10-11 18:06   ` [PATCH 1/8] xfs: convert the rtbitmap block and bit macros to static inline functions Darrick J. Wong
2023-10-12  6:34     ` Christoph Hellwig
2023-10-11 18:06   ` [PATCH 2/8] xfs: remove XFS_BLOCKWSIZE and XFS_BLOCKWMASK macros Darrick J. Wong
2023-10-12  5:33     ` Christoph Hellwig
2023-10-12 18:20       ` Darrick J. Wong
2023-10-13  5:53         ` Christoph Hellwig
2023-10-17  0:49           ` Darrick J. Wong
2023-10-11 18:07   ` [PATCH 3/8] xfs: convert open-coded xfs_rtword_t pointer accesses to helper Darrick J. Wong
2023-10-12  5:39     ` Christoph Hellwig
2023-10-12 18:26       ` Darrick J. Wong
2023-10-11 18:07   ` [PATCH 4/8] xfs: convert rt summary macros to helpers Darrick J. Wong
2023-10-12  5:41     ` Christoph Hellwig
2023-10-11 18:07   ` [PATCH 5/8] xfs: create helpers for rtbitmap block/wordcount computations Darrick J. Wong
2023-10-12  5:44     ` Christoph Hellwig
2023-10-12 21:55       ` Darrick J. Wong
2023-10-13  4:26         ` Christoph Hellwig
2023-10-11 18:07   ` [PATCH 6/8] xfs: use accessor functions for bitmap words Darrick J. Wong
2023-10-12  6:19     ` Christoph Hellwig
2023-10-12 22:11       ` Darrick J. Wong
2023-10-13  4:28         ` Christoph Hellwig
2023-10-13 16:58           ` Darrick J. Wong
2023-10-11 18:08   ` [PATCH 7/8] xfs: create helpers for rtsummary block/wordcount computations Darrick J. Wong
2023-10-12  6:25     ` Christoph Hellwig
2023-10-12 22:18       ` Darrick J. Wong
2023-10-13  4:29         ` Christoph Hellwig
2023-10-13 17:11           ` Darrick J. Wong
2023-10-11 18:08   ` [PATCH 8/8] xfs: use accessor functions for summary info words Darrick J. Wong
2023-10-12  6:26     ` Christoph Hellwig
2023-10-12 22:21       ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2023-10-19 16:20 [PATCHSET v1.1 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2023-10-19 16:25 ` [PATCH 5/7] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls Darrick J. Wong
2023-10-17 15:46 [PATCHSET RFC v1.1 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2023-10-17 15:51 ` [PATCH 5/7] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls Darrick J. Wong
2023-10-17 16:05   ` Christoph Hellwig
2022-12-30 22:17 [PATCHSET v1.0 0/7] xfs: refactor rt extent unit conversions Darrick J. Wong
2022-12-30 22:17 ` [PATCH 5/7] xfs: convert do_div calls to xfs_rtb_to_rtx helper calls Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=169704721255.1773611.7719978115841778913.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=osandov@osandov.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.