]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: make is_log_ag() a first class helper
authorDave Chinner <dchinner@redhat.com>
Mon, 22 Aug 2022 14:17:22 +0000 (16:17 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 30 Aug 2022 08:13:59 +0000 (10:13 +0200)
Source kernel commit: 36029dee382a20cf515494376ce9f0d5949944eb

We check if an ag contains the log in many places, so make this
a first class XFS helper by lifting it to fs/xfs/libxfs/xfs_ag.h and
renaming it xfs_ag_contains_log(). The convert all the places that
check if the AG contains the log to use this helper.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_ag.c
libxfs/xfs_ag.h
libxfs/xfs_ialloc.c
libxfs/xfs_ialloc_btree.c
libxfs/xfs_refcount_btree.c
libxfs/xfs_rmap_btree.c

index 44ed5a592c34cd9e7c42f309e985936678f7328a..7515dd12783fd3694bf83268c4e46288b644a0be 100644 (file)
@@ -388,12 +388,6 @@ xfs_get_aghdr_buf(
        return 0;
 }
 
-static inline bool is_log_ag(struct xfs_mount *mp, struct aghdr_init_data *id)
-{
-       return mp->m_sb.sb_logstart > 0 &&
-              id->agno == XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart);
-}
-
 /*
  * Generic btree root block init function
  */
@@ -419,7 +413,7 @@ xfs_freesp_init_recs(
        arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1);
        arec->ar_startblock = cpu_to_be32(mp->m_ag_prealloc_blocks);
 
-       if (is_log_ag(mp, id)) {
+       if (xfs_ag_contains_log(mp, id->agno)) {
                struct xfs_alloc_rec    *nrec;
                xfs_agblock_t           start = XFS_FSB_TO_AGBNO(mp,
                                                        mp->m_sb.sb_logstart);
@@ -546,7 +540,7 @@ xfs_rmaproot_init(
        }
 
        /* account for the log space */
-       if (is_log_ag(mp, id)) {
+       if (xfs_ag_contains_log(mp, id->agno)) {
                rrec = XFS_RMAP_REC_ADDR(block,
                                be16_to_cpu(block->bb_numrecs) + 1);
                rrec->rm_startblock = cpu_to_be32(
@@ -617,7 +611,7 @@ xfs_agfblock_init(
                agf->agf_refcount_blocks = cpu_to_be32(1);
        }
 
-       if (is_log_ag(mp, id)) {
+       if (xfs_ag_contains_log(mp, id->agno)) {
                int64_t logblocks = mp->m_sb.sb_logblocks;
 
                be32_add_cpu(&agf->agf_freeblks, -logblocks);
index bb9e91bd38e2855f921e5eeec9d37e8e95012756..75f7c10c110a5e789525fb39ab6d7fa70de51a36 100644 (file)
@@ -165,6 +165,13 @@ xfs_verify_agino_or_null(struct xfs_perag *pag, xfs_agino_t agino)
        return xfs_verify_agino(pag, agino);
 }
 
+static inline bool
+xfs_ag_contains_log(struct xfs_mount *mp, xfs_agnumber_t agno)
+{
+       return mp->m_sb.sb_logstart > 0 &&
+              agno == XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart);
+}
+
 /*
  * Perag iteration APIs
  */
index f18ea6752dd0f35099c75dd64360d2b9264476d3..f27de1fdd0738cee76d5ea9d09da21f6a775443b 100644 (file)
@@ -2892,8 +2892,7 @@ xfs_ialloc_calc_rootino(
         * allocation group, or very odd geometries created by old mkfs
         * versions on very small filesystems.
         */
-       if (mp->m_sb.sb_logstart &&
-           XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == 0)
+       if (xfs_ag_contains_log(mp, 0))
                 first_bno += mp->m_sb.sb_logblocks;
 
        /*
index 67fe535ff2d0419d14b8735cefc0c253539edea6..b230a5827ab141f1d00b79bc62fd598c79fc8fae 100644 (file)
@@ -696,8 +696,7 @@ xfs_inobt_max_size(
         * never be available for the kinds of things that would require btree
         * expansion.  We therefore can pretend the space isn't there.
         */
-       if (mp->m_sb.sb_logstart &&
-           XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
+       if (xfs_ag_contains_log(mp, pag->pag_agno))
                agblocks -= mp->m_sb.sb_logblocks;
 
        return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr,
index d57445f68cd3e86c22e7925103ee8233ec0aa1a7..0707cbc024f10b9a984d78fe5327d683a65c7f07 100644 (file)
@@ -506,8 +506,7 @@ xfs_refcountbt_calc_reserves(
         * never be available for the kinds of things that would require btree
         * expansion.  We therefore can pretend the space isn't there.
         */
-       if (mp->m_sb.sb_logstart &&
-           XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
+       if (xfs_ag_contains_log(mp, pag->pag_agno))
                agblocks -= mp->m_sb.sb_logblocks;
 
        *ask += xfs_refcountbt_max_size(mp, agblocks);
index 486a53969f3df83414fadc21294ed1c131682ef5..d2d184304c64a69ad0c568860529d2cb6e2173b5 100644 (file)
@@ -664,8 +664,7 @@ xfs_rmapbt_calc_reserves(
         * never be available for the kinds of things that would require btree
         * expansion.  We therefore can pretend the space isn't there.
         */
-       if (mp->m_sb.sb_logstart &&
-           XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
+       if (xfs_ag_contains_log(mp, pag->pag_agno))
                agblocks -= mp->m_sb.sb_logblocks;
 
        /* Reserve 1% of the AG or enough for 1 block per record. */