]> Git Repo - J-linux.git/commitdiff
xfs: make is_log_ag() a first class helper
authorDave Chinner <[email protected]>
Thu, 7 Jul 2022 09:13:21 +0000 (19:13 +1000)
committerDave Chinner <[email protected]>
Thu, 7 Jul 2022 09:13:21 +0000 (19:13 +1000)
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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_ag.h
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_ialloc_btree.c
fs/xfs/libxfs/xfs_refcount_btree.c
fs/xfs/libxfs/xfs_rmap_btree.c
fs/xfs/scrub/health.c
fs/xfs/scrub/refcount.c

index d1a9163d4a4839b376ee62af5cd006362d243584..71f5dae7ad6c22124172a62affb797bbce95fb45 100644 (file)
@@ -390,12 +390,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
  */
@@ -421,7 +415,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);
@@ -548,7 +542,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(
@@ -619,7 +613,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 39ad3b7af5022b42083e1db2cb40f850fbba4473..6cdfd64bc56bdd2132721a38edf5c16a7e9fc64a 100644 (file)
@@ -2897,8 +2897,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 2e0ff99d9f0b1f6b137044d19f3ccea925bbf09c..8c83e265770c107affb1b9d5b7ace07d4e979b7f 100644 (file)
@@ -697,8 +697,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 1063234df34a42f866d87b3c1127faf318d9dbca..316c1ec0c3c26d31e243cd3174293826dfe61a89 100644 (file)
@@ -507,8 +507,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 1ae14d0c831ca911922a670dd62defef7adff2ed..7f83f62e51e0bf36c9f16316d2faa9c97930673f 100644 (file)
@@ -666,8 +666,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. */
index 2e61df3bca833541867236bb716e96754e394d95..aa65ec88a0c006a4c897a6174d51c193b6ce6529 100644 (file)
@@ -8,6 +8,8 @@
 #include "xfs_shared.h"
 #include "xfs_format.h"
 #include "xfs_btree.h"
+#include "xfs_trans_resv.h"
+#include "xfs_mount.h"
 #include "xfs_ag.h"
 #include "xfs_health.h"
 #include "scrub/scrub.h"
index 3f82a1a1f3906fc3e90aa51468be0c80c7caf6be..c68b767dc08fe103fb72650d2d5a1ee5a6d99266 100644 (file)
@@ -13,6 +13,8 @@
 #include "scrub/scrub.h"
 #include "scrub/common.h"
 #include "scrub/btree.h"
+#include "xfs_trans_resv.h"
+#include "xfs_mount.h"
 #include "xfs_ag.h"
 
 /*
This page took 0.085117 seconds and 4 git commands to generate.