diff mbox series

[2/5] xfs: use the finobt block counts to speed up mount times

Message ID 159858220352.3058056.14870764546265114620.stgit@magnolia (mailing list archive)
State Superseded
Headers show
Series xfs: add inode btree blocks counters to the AGI header | expand

Commit Message

Darrick J. Wong Aug. 28, 2020, 2:36 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Now that we have reliable finobt block counts, use them to speed up the
per-AG block reservation calculations at mount time.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/libxfs/xfs_ialloc_btree.c |   28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

Comments

Brian Foster Aug. 31, 2020, 7:06 p.m. UTC | #1
On Thu, Aug 27, 2020 at 07:36:43PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Now that we have reliable finobt block counts, use them to speed up the
> per-AG block reservation calculations at mount time.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_ialloc_btree.c |   28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
> index ee9d407ab9da..a5461091ba7b 100644
> --- a/fs/xfs/libxfs/xfs_ialloc_btree.c
> +++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
> @@ -694,6 +694,28 @@ xfs_inobt_count_blocks(
>  	return error;
>  }
>  
> +/* Read finobt block count from AGI header. */
> +static int
> +xfs_finobt_read_blocks(
> +	struct xfs_mount	*mp,
> +	struct xfs_trans	*tp,
> +	xfs_agnumber_t		agno,
> +	xfs_extlen_t		*tree_blocks)
> +{
> +	struct xfs_buf		*agbp;
> +	struct xfs_agi		*agi;
> +	int			error;
> +
> +	error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
> +	if (error)
> +		return error;
> +
> +	agi = agbp->b_addr;
> +	*tree_blocks = be32_to_cpu(agi->agi_fblocks);
> +	xfs_trans_brelse(tp, agbp);
> +	return 0;
> +}
> +
>  /*
>   * Figure out how many blocks to reserve and how many are used by this btree.
>   */
> @@ -711,7 +733,11 @@ xfs_finobt_calc_reserves(
>  	if (!xfs_sb_version_hasfinobt(&mp->m_sb))
>  		return 0;
>  
> -	error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO, &tree_len);
> +	if (xfs_sb_version_hasinobtcounts(&mp->m_sb))
> +		error = xfs_finobt_read_blocks(mp, tp, agno, &tree_len);
> +	else
> +		error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO,
> +				&tree_len);
>  	if (error)
>  		return error;
>  
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index ee9d407ab9da..a5461091ba7b 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -694,6 +694,28 @@  xfs_inobt_count_blocks(
 	return error;
 }
 
+/* Read finobt block count from AGI header. */
+static int
+xfs_finobt_read_blocks(
+	struct xfs_mount	*mp,
+	struct xfs_trans	*tp,
+	xfs_agnumber_t		agno,
+	xfs_extlen_t		*tree_blocks)
+{
+	struct xfs_buf		*agbp;
+	struct xfs_agi		*agi;
+	int			error;
+
+	error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
+	if (error)
+		return error;
+
+	agi = agbp->b_addr;
+	*tree_blocks = be32_to_cpu(agi->agi_fblocks);
+	xfs_trans_brelse(tp, agbp);
+	return 0;
+}
+
 /*
  * Figure out how many blocks to reserve and how many are used by this btree.
  */
@@ -711,7 +733,11 @@  xfs_finobt_calc_reserves(
 	if (!xfs_sb_version_hasfinobt(&mp->m_sb))
 		return 0;
 
-	error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO, &tree_len);
+	if (xfs_sb_version_hasinobtcounts(&mp->m_sb))
+		error = xfs_finobt_read_blocks(mp, tp, agno, &tree_len);
+	else
+		error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO,
+				&tree_len);
 	if (error)
 		return error;