Blame SOURCES/xfsprogs-5.10.0-xfs-use-the-finobt-block-counts-to-speed-up-mount-ti.patch

f49185
From eb2c6897f36d560f84ed5124b246f2759c470f11 Mon Sep 17 00:00:00 2001
f49185
From: "Darrick J. Wong" <darrick.wong@oracle.com>
f49185
Date: Tue, 10 Nov 2020 15:11:09 -0500
f49185
Subject: [PATCH] xfs: use the finobt block counts to speed up mount times
f49185
f49185
Source kernel commit: 1ac35f061af011442eeb731632f6daae991ecf7c
f49185
f49185
Now that we have reliable finobt block counts, use them to speed up the
f49185
per-AG block reservation calculations at mount time.
f49185
f49185
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
f49185
Reviewed-by: Brian Foster <bfoster@redhat.com>
f49185
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
f49185
---
f49185
f49185
diff --git a/libxfs/xfs_ialloc_btree.c b/libxfs/xfs_ialloc_btree.c
f49185
index 9db87e9..b1adc80 100644
f49185
--- a/libxfs/xfs_ialloc_btree.c
f49185
+++ b/libxfs/xfs_ialloc_btree.c
f49185
@@ -593,6 +593,28 @@ xfs_inobt_count_blocks(
f49185
 	return error;
f49185
 }
f49185
 
f49185
+/* Read finobt block count from AGI header. */
f49185
+static int
f49185
+xfs_finobt_read_blocks(
f49185
+	struct xfs_mount	*mp,
f49185
+	struct xfs_trans	*tp,
f49185
+	xfs_agnumber_t		agno,
f49185
+	xfs_extlen_t		*tree_blocks)
f49185
+{
f49185
+	struct xfs_buf		*agbp;
f49185
+	struct xfs_agi		*agi;
f49185
+	int			error;
f49185
+
f49185
+	error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
f49185
+	if (error)
f49185
+		return error;
f49185
+
f49185
+	agi = agbp->b_addr;
f49185
+	*tree_blocks = be32_to_cpu(agi->agi_fblocks);
f49185
+	xfs_trans_brelse(tp, agbp);
f49185
+	return 0;
f49185
+}
f49185
+
f49185
 /*
f49185
  * Figure out how many blocks to reserve and how many are used by this btree.
f49185
  */
f49185
@@ -610,7 +632,11 @@ xfs_finobt_calc_reserves(
f49185
 	if (!xfs_sb_version_hasfinobt(&mp->m_sb))
f49185
 		return 0;
f49185
 
f49185
-	error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO, &tree_len);
f49185
+	if (xfs_sb_version_hasinobtcounts(&mp->m_sb))
f49185
+		error = xfs_finobt_read_blocks(mp, tp, agno, &tree_len);
f49185
+	else
f49185
+		error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO,
f49185
+				&tree_len);
f49185
 	if (error)
f49185
 		return error;
f49185