]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: factor out a xfs_last_rt_bmblock helper
authorChristoph Hellwig <hch@lst.de>
Tue, 30 Jul 2024 17:54:11 +0000 (10:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 1 Aug 2024 00:10:07 +0000 (17:10 -0700)
Add helper to calculate the last currently used rt bitmap block to
better structure the growfs code and prepare for future changes to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_rtalloc.c

index 9475e75b442fd868f22f51469405993fe7145c0a..c1caa60cd9f1b21933928b2a785776aa9b33728a 100644 (file)
@@ -917,6 +917,23 @@ out_free:
        return error;
 }
 
+/*
+ * Calculate the last rbmblock currently used.
+ *
+ * This also deals with the case where there were no rtextents before.
+ */
+static xfs_fileoff_t
+xfs_last_rt_bmblock(
+       struct xfs_mount        *mp)
+{
+       xfs_fileoff_t           bmbno = mp->m_sb.sb_rbmblocks;
+
+       /* Skip the current block if it is exactly full. */
+       if (xfs_rtx_to_rbmword(mp, mp->m_sb.sb_rextents) != 0)
+               bmbno--;
+       return bmbno;
+}
+
 /*
  * Grow the realtime area of the filesystem.
  */
@@ -1018,16 +1035,8 @@ xfs_growfs_rt(
                        return error;
        }
 
-       /*
-        * Loop over the bitmap blocks.
-        * We will do everything one bitmap block at a time.
-        * Skip the current block if it is exactly full.
-        * This also deals with the case where there were no rtextents before.
-        */
-       bmbno = mp->m_sb.sb_rbmblocks;
-       if (xfs_rtx_to_rbmword(mp, mp->m_sb.sb_rextents) != 0)
-               bmbno--;
-       for (; bmbno < nrbmblocks; bmbno++) {
+       /* Initialize the free space bitmap one bitmap block at a time. */
+       for (bmbno = xfs_last_rt_bmblock(mp); bmbno < nrbmblocks; bmbno++) {
                error = xfs_growfs_rt_bmblock(mp, in->newblocks, in->extsize,
                                bmbno);
                if (error)