summaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-08-31 00:36:58 +0200
committerDarrick J. Wong <djwong@kernel.org>2024-09-01 17:58:19 +0200
commit266e78aec4b9bac0400b09603a2bd24bea7268df (patch)
treee953c6125be2ac148c9e3832b233743b56595868 /fs/xfs
parentxfs: factor out a xfs_growfs_rt_bmblock helper (diff)
downloadlinux-266e78aec4b9bac0400b09603a2bd24bea7268df.tar.xz
linux-266e78aec4b9bac0400b09603a2bd24bea7268df.zip
xfs: factor out a xfs_last_rt_bmblock helper
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>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_rtalloc.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index febd039718ee..45a0d29949ea 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -949,6 +949,23 @@ out_free:
}
/*
+ * 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.
*/
int
@@ -1059,16 +1076,8 @@ xfs_growfs_rt(
goto out_unlock;
}
- /*
- * 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)