Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: Pre-calculate per-AG agbno geometry

There is a lot of overhead in functions like xfs_verify_agbno() that
repeatedly calculate the geometry limits of an AG. These can be
pre-calculated as they are static and the verification context has
a per-ag context it can quickly reference.

In the case of xfs_verify_agbno(), we now always have a perag
context handy, so we can store the AG length and the minimum valid
block in the AG in the perag. This means we don't have to calculate
it on every call and it can be inlined in callers if we move it
to xfs_ag.h.

Move xfs_ag_block_count() to xfs_ag.c because it's really a
per-ag function and not an XFS type function. We need a little
bit of rework that is specific to xfs_initialise_perag() to allow
growfs to calculate the new perag sizes before we've updated the
primary superblock during the grow (chicken/egg situation).

Note that we leave the original xfs_verify_agbno in place in
xfs_types.c as a static function as other callers in that file do
not have per-ag contexts so still need to go the long way. It's been
renamed to xfs_verify_agno_agbno() to indicate it takes both an agno
and an agbno to differentiate it from new function.

Future commits will make similar changes for other per-ag geometry
validation functions.

Further:

$ size --totals fs/xfs/built-in.a
text data bss dec hex filename
before 1483006 329588 572 1813166 1baaae (TOTALS)
after 1482185 329588 572 1812345 1ba779 (TOTALS)

This rework reduces the binary size by ~820 bytes, indicating
that much less work is being done to bounds check the agbno values
against on per-ag geometry information.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

authored by

Dave Chinner and committed by
Dave Chinner
0800169e cec7bb7d

+115 -82
+39 -1
fs/xfs/libxfs/xfs_ag.c
··· 201 201 } 202 202 } 203 203 204 + /* Find the size of the AG, in blocks. */ 205 + static xfs_agblock_t 206 + __xfs_ag_block_count( 207 + struct xfs_mount *mp, 208 + xfs_agnumber_t agno, 209 + xfs_agnumber_t agcount, 210 + xfs_rfsblock_t dblocks) 211 + { 212 + ASSERT(agno < agcount); 213 + 214 + if (agno < agcount - 1) 215 + return mp->m_sb.sb_agblocks; 216 + return dblocks - (agno * mp->m_sb.sb_agblocks); 217 + } 218 + 219 + xfs_agblock_t 220 + xfs_ag_block_count( 221 + struct xfs_mount *mp, 222 + xfs_agnumber_t agno) 223 + { 224 + return __xfs_ag_block_count(mp, agno, mp->m_sb.sb_agcount, 225 + mp->m_sb.sb_dblocks); 226 + } 227 + 204 228 int 205 229 xfs_initialize_perag( 206 230 struct xfs_mount *mp, 207 231 xfs_agnumber_t agcount, 232 + xfs_rfsblock_t dblocks, 208 233 xfs_agnumber_t *maxagi) 209 234 { 210 235 struct xfs_perag *pag; ··· 295 270 /* first new pag is fully initialized */ 296 271 if (first_initialised == NULLAGNUMBER) 297 272 first_initialised = index; 273 + 274 + /* 275 + * Pre-calculated geometry 276 + */ 277 + pag->block_count = __xfs_ag_block_count(mp, index, agcount, 278 + dblocks); 279 + pag->min_block = XFS_AGFL_BLOCK(mp); 298 280 } 299 281 300 282 index = xfs_set_inode_alloc(mp, agcount); ··· 959 927 if (error) 960 928 return error; 961 929 962 - return xfs_free_extent(tp, XFS_AGB_TO_FSB(pag->pag_mount, pag->pag_agno, 930 + error = xfs_free_extent(tp, XFS_AGB_TO_FSB(pag->pag_mount, pag->pag_agno, 963 931 be32_to_cpu(agf->agf_length) - len), 964 932 len, &XFS_RMAP_OINFO_SKIP_UPDATE, 965 933 XFS_AG_RESV_NONE); 934 + if (error) 935 + return error; 936 + 937 + /* Update perag geometry */ 938 + pag->block_count = be32_to_cpu(agf->agf_length); 939 + return 0; 966 940 } 967 941 968 942 /* Retrieve AG geometry. */
+20 -1
fs/xfs/libxfs/xfs_ag.h
··· 67 67 /* for rcu-safe freeing */ 68 68 struct rcu_head rcu_head; 69 69 70 + /* Precalculated geometry info */ 71 + xfs_agblock_t block_count; 72 + xfs_agblock_t min_block; 73 + 70 74 #ifdef __KERNEL__ 71 75 /* -- kernel only structures below this line -- */ 72 76 ··· 111 107 }; 112 108 113 109 int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t agcount, 114 - xfs_agnumber_t *maxagi); 110 + xfs_rfsblock_t dcount, xfs_agnumber_t *maxagi); 115 111 int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno); 116 112 void xfs_free_perag(struct xfs_mount *mp); 117 113 ··· 119 115 struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *mp, xfs_agnumber_t agno, 120 116 unsigned int tag); 121 117 void xfs_perag_put(struct xfs_perag *pag); 118 + 119 + /* 120 + * Per-ag geometry infomation and validation 121 + */ 122 + xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno); 123 + 124 + static inline bool 125 + xfs_verify_agbno(struct xfs_perag *pag, xfs_agblock_t agbno) 126 + { 127 + if (agbno >= pag->block_count) 128 + return false; 129 + if (agbno <= pag->min_block) 130 + return false; 131 + return true; 132 + } 122 133 123 134 /* 124 135 * Perag iteration APIs
+5 -4
fs/xfs/libxfs/xfs_alloc.c
··· 248 248 int *stat) /* output: success/failure */ 249 249 { 250 250 struct xfs_mount *mp = cur->bc_mp; 251 - xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; 251 + struct xfs_perag *pag = cur->bc_ag.pag; 252 252 union xfs_btree_rec *rec; 253 253 int error; 254 254 ··· 263 263 goto out_bad_rec; 264 264 265 265 /* check for valid extent range, including overflow */ 266 - if (!xfs_verify_agbno(mp, agno, *bno)) 266 + if (!xfs_verify_agbno(pag, *bno)) 267 267 goto out_bad_rec; 268 268 if (*bno > *bno + *len) 269 269 goto out_bad_rec; 270 - if (!xfs_verify_agbno(mp, agno, *bno + *len - 1)) 270 + if (!xfs_verify_agbno(pag, *bno + *len - 1)) 271 271 goto out_bad_rec; 272 272 273 273 return 0; ··· 275 275 out_bad_rec: 276 276 xfs_warn(mp, 277 277 "%s Freespace BTree record corruption in AG %d detected!", 278 - cur->bc_btnum == XFS_BTNUM_BNO ? "Block" : "Size", agno); 278 + cur->bc_btnum == XFS_BTNUM_BNO ? "Block" : "Size", 279 + pag->pag_agno); 279 280 xfs_warn(mp, 280 281 "start block 0x%x block count 0x%x", *bno, *len); 281 282 return -EFSCORRUPTED;
+10 -15
fs/xfs/libxfs/xfs_btree.c
··· 91 91 92 92 static inline xfs_failaddr_t 93 93 xfs_btree_check_sblock_siblings( 94 - struct xfs_mount *mp, 94 + struct xfs_perag *pag, 95 95 struct xfs_btree_cur *cur, 96 96 int level, 97 - xfs_agnumber_t agno, 98 97 xfs_agblock_t agbno, 99 98 __be32 dsibling) 100 99 { ··· 109 110 if (!xfs_btree_check_sptr(cur, sibling, level + 1)) 110 111 return __this_address; 111 112 } else { 112 - if (!xfs_verify_agbno(mp, agno, sibling)) 113 + if (!xfs_verify_agbno(pag, sibling)) 113 114 return __this_address; 114 115 } 115 116 return NULL; ··· 194 195 struct xfs_buf *bp) 195 196 { 196 197 struct xfs_mount *mp = cur->bc_mp; 198 + struct xfs_perag *pag = cur->bc_ag.pag; 197 199 xfs_btnum_t btnum = cur->bc_btnum; 198 200 int crc = xfs_has_crc(mp); 199 201 xfs_failaddr_t fa; 200 202 xfs_agblock_t agbno = NULLAGBLOCK; 201 - xfs_agnumber_t agno = NULLAGNUMBER; 202 203 203 204 if (crc) { 204 205 if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid)) ··· 216 217 cur->bc_ops->get_maxrecs(cur, level)) 217 218 return __this_address; 218 219 219 - if (bp) { 220 + if (bp) 220 221 agbno = xfs_daddr_to_agbno(mp, xfs_buf_daddr(bp)); 221 - agno = xfs_daddr_to_agno(mp, xfs_buf_daddr(bp)); 222 - } 223 222 224 - fa = xfs_btree_check_sblock_siblings(mp, cur, level, agno, agbno, 223 + fa = xfs_btree_check_sblock_siblings(pag, cur, level, agbno, 225 224 block->bb_u.s.bb_leftsib); 226 225 if (!fa) 227 - fa = xfs_btree_check_sblock_siblings(mp, cur, level, agno, 228 - agbno, block->bb_u.s.bb_rightsib); 226 + fa = xfs_btree_check_sblock_siblings(pag, cur, level, agbno, 227 + block->bb_u.s.bb_rightsib); 229 228 return fa; 230 229 } 231 230 ··· 285 288 { 286 289 if (level <= 0) 287 290 return false; 288 - return xfs_verify_agbno(cur->bc_mp, cur->bc_ag.pag->pag_agno, agbno); 291 + return xfs_verify_agbno(cur->bc_ag.pag, agbno); 289 292 } 290 293 291 294 /* ··· 4592 4595 { 4593 4596 struct xfs_mount *mp = bp->b_mount; 4594 4597 struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); 4595 - xfs_agnumber_t agno; 4596 4598 xfs_agblock_t agbno; 4597 4599 xfs_failaddr_t fa; 4598 4600 ··· 4600 4604 return __this_address; 4601 4605 4602 4606 /* sibling pointer verification */ 4603 - agno = xfs_daddr_to_agno(mp, xfs_buf_daddr(bp)); 4604 4607 agbno = xfs_daddr_to_agbno(mp, xfs_buf_daddr(bp)); 4605 - fa = xfs_btree_check_sblock_siblings(mp, NULL, -1, agno, agbno, 4608 + fa = xfs_btree_check_sblock_siblings(bp->b_pag, NULL, -1, agbno, 4606 4609 block->bb_u.s.bb_leftsib); 4607 4610 if (!fa) 4608 - fa = xfs_btree_check_sblock_siblings(mp, NULL, -1, agno, agbno, 4611 + fa = xfs_btree_check_sblock_siblings(bp->b_pag, NULL, -1, agbno, 4609 4612 block->bb_u.s.bb_rightsib); 4610 4613 return fa; 4611 4614 }
+6 -7
fs/xfs/libxfs/xfs_refcount.c
··· 111 111 int *stat) 112 112 { 113 113 struct xfs_mount *mp = cur->bc_mp; 114 - xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; 114 + struct xfs_perag *pag = cur->bc_ag.pag; 115 115 union xfs_btree_rec *rec; 116 116 int error; 117 117 xfs_agblock_t realstart; ··· 121 121 return error; 122 122 123 123 xfs_refcount_btrec_to_irec(rec, irec); 124 - 125 - agno = cur->bc_ag.pag->pag_agno; 126 124 if (irec->rc_blockcount == 0 || irec->rc_blockcount > MAXREFCEXTLEN) 127 125 goto out_bad_rec; 128 126 ··· 135 137 } 136 138 137 139 /* check for valid extent range, including overflow */ 138 - if (!xfs_verify_agbno(mp, agno, realstart)) 140 + if (!xfs_verify_agbno(pag, realstart)) 139 141 goto out_bad_rec; 140 142 if (realstart > realstart + irec->rc_blockcount) 141 143 goto out_bad_rec; 142 - if (!xfs_verify_agbno(mp, agno, realstart + irec->rc_blockcount - 1)) 144 + if (!xfs_verify_agbno(pag, realstart + irec->rc_blockcount - 1)) 143 145 goto out_bad_rec; 144 146 145 147 if (irec->rc_refcount == 0 || irec->rc_refcount > MAXREFCOUNT) 146 148 goto out_bad_rec; 147 149 148 - trace_xfs_refcount_get(cur->bc_mp, cur->bc_ag.pag->pag_agno, irec); 150 + trace_xfs_refcount_get(cur->bc_mp, pag->pag_agno, irec); 149 151 return 0; 150 152 151 153 out_bad_rec: 152 154 xfs_warn(mp, 153 - "Refcount BTree record corruption in AG %d detected!", agno); 155 + "Refcount BTree record corruption in AG %d detected!", 156 + pag->pag_agno); 154 157 xfs_warn(mp, 155 158 "Start block 0x%x, block count 0x%x, references 0x%x", 156 159 irec->rc_startblock, irec->rc_blockcount, irec->rc_refcount);
+4 -4
fs/xfs/libxfs/xfs_rmap.c
··· 215 215 int *stat) 216 216 { 217 217 struct xfs_mount *mp = cur->bc_mp; 218 - xfs_agnumber_t agno = cur->bc_ag.pag->pag_agno; 218 + struct xfs_perag *pag = cur->bc_ag.pag; 219 219 union xfs_btree_rec *rec; 220 220 int error; 221 221 ··· 235 235 goto out_bad_rec; 236 236 } else { 237 237 /* check for valid extent range, including overflow */ 238 - if (!xfs_verify_agbno(mp, agno, irec->rm_startblock)) 238 + if (!xfs_verify_agbno(pag, irec->rm_startblock)) 239 239 goto out_bad_rec; 240 240 if (irec->rm_startblock > 241 241 irec->rm_startblock + irec->rm_blockcount) 242 242 goto out_bad_rec; 243 - if (!xfs_verify_agbno(mp, agno, 243 + if (!xfs_verify_agbno(pag, 244 244 irec->rm_startblock + irec->rm_blockcount - 1)) 245 245 goto out_bad_rec; 246 246 } ··· 254 254 out_bad_rec: 255 255 xfs_warn(mp, 256 256 "Reverse Mapping BTree record corruption in AG %d detected!", 257 - agno); 257 + pag->pag_agno); 258 258 xfs_warn(mp, 259 259 "Owner 0x%llx, flags 0x%x, start block 0x%x block count 0x%x", 260 260 irec->rm_owner, irec->rm_flags, irec->rm_startblock,
+3 -15
fs/xfs/libxfs/xfs_types.c
··· 13 13 #include "xfs_mount.h" 14 14 #include "xfs_ag.h" 15 15 16 - /* Find the size of the AG, in blocks. */ 17 - inline xfs_agblock_t 18 - xfs_ag_block_count( 19 - struct xfs_mount *mp, 20 - xfs_agnumber_t agno) 21 - { 22 - ASSERT(agno < mp->m_sb.sb_agcount); 23 - 24 - if (agno < mp->m_sb.sb_agcount - 1) 25 - return mp->m_sb.sb_agblocks; 26 - return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks); 27 - } 28 16 29 17 /* 30 18 * Verify that an AG block number pointer neither points outside the AG 31 19 * nor points at static metadata. 32 20 */ 33 - inline bool 34 - xfs_verify_agbno( 21 + static inline bool 22 + xfs_verify_agno_agbno( 35 23 struct xfs_mount *mp, 36 24 xfs_agnumber_t agno, 37 25 xfs_agblock_t agbno) ··· 47 59 48 60 if (agno >= mp->m_sb.sb_agcount) 49 61 return false; 50 - return xfs_verify_agbno(mp, agno, XFS_FSB_TO_AGBNO(mp, fsbno)); 62 + return xfs_verify_agno_agbno(mp, agno, XFS_FSB_TO_AGBNO(mp, fsbno)); 51 63 } 52 64 53 65 /*
-3
fs/xfs/libxfs/xfs_types.h
··· 179 179 */ 180 180 struct xfs_mount; 181 181 182 - xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno); 183 - bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno, 184 - xfs_agblock_t agbno); 185 182 bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno); 186 183 bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno, 187 184 xfs_fsblock_t len);
+9 -10
fs/xfs/scrub/agheader.c
··· 541 541 542 542 /* Check the AG length */ 543 543 eoag = be32_to_cpu(agf->agf_length); 544 - if (eoag != xfs_ag_block_count(mp, agno)) 544 + if (eoag != pag->block_count) 545 545 xchk_block_set_corrupt(sc, sc->sa.agf_bp); 546 546 547 547 /* Check the AGF btree roots and levels */ 548 548 agbno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]); 549 - if (!xfs_verify_agbno(mp, agno, agbno)) 549 + if (!xfs_verify_agbno(pag, agbno)) 550 550 xchk_block_set_corrupt(sc, sc->sa.agf_bp); 551 551 552 552 agbno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]); 553 - if (!xfs_verify_agbno(mp, agno, agbno)) 553 + if (!xfs_verify_agbno(pag, agbno)) 554 554 xchk_block_set_corrupt(sc, sc->sa.agf_bp); 555 555 556 556 level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]); ··· 563 563 564 564 if (xfs_has_rmapbt(mp)) { 565 565 agbno = be32_to_cpu(agf->agf_roots[XFS_BTNUM_RMAP]); 566 - if (!xfs_verify_agbno(mp, agno, agbno)) 566 + if (!xfs_verify_agbno(pag, agbno)) 567 567 xchk_block_set_corrupt(sc, sc->sa.agf_bp); 568 568 569 569 level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]); ··· 573 573 574 574 if (xfs_has_reflink(mp)) { 575 575 agbno = be32_to_cpu(agf->agf_refcount_root); 576 - if (!xfs_verify_agbno(mp, agno, agbno)) 576 + if (!xfs_verify_agbno(pag, agbno)) 577 577 xchk_block_set_corrupt(sc, sc->sa.agf_bp); 578 578 579 579 level = be32_to_cpu(agf->agf_refcount_level); ··· 639 639 { 640 640 struct xchk_agfl_info *sai = priv; 641 641 struct xfs_scrub *sc = sai->sc; 642 - xfs_agnumber_t agno = sc->sa.pag->pag_agno; 643 642 644 - if (xfs_verify_agbno(mp, agno, agbno) && 643 + if (xfs_verify_agbno(sc->sa.pag, agbno) && 645 644 sai->nr_entries < sai->sz_entries) 646 645 sai->entries[sai->nr_entries++] = agbno; 647 646 else ··· 870 871 871 872 /* Check the AG length */ 872 873 eoag = be32_to_cpu(agi->agi_length); 873 - if (eoag != xfs_ag_block_count(mp, agno)) 874 + if (eoag != pag->block_count) 874 875 xchk_block_set_corrupt(sc, sc->sa.agi_bp); 875 876 876 877 /* Check btree roots and levels */ 877 878 agbno = be32_to_cpu(agi->agi_root); 878 - if (!xfs_verify_agbno(mp, agno, agbno)) 879 + if (!xfs_verify_agbno(pag, agbno)) 879 880 xchk_block_set_corrupt(sc, sc->sa.agi_bp); 880 881 881 882 level = be32_to_cpu(agi->agi_level); ··· 884 885 885 886 if (xfs_has_finobt(mp)) { 886 887 agbno = be32_to_cpu(agi->agi_free_root); 887 - if (!xfs_verify_agbno(mp, agno, agbno)) 888 + if (!xfs_verify_agbno(pag, agbno)) 888 889 xchk_block_set_corrupt(sc, sc->sa.agi_bp); 889 890 890 891 level = be32_to_cpu(agi->agi_free_level);
+2 -5
fs/xfs/scrub/agheader_repair.c
··· 106 106 { 107 107 struct xfs_scrub *sc = priv; 108 108 109 - if (!xfs_verify_agbno(mp, sc->sa.pag->pag_agno, agbno)) 109 + if (!xfs_verify_agbno(sc->sa.pag, agbno)) 110 110 return -EFSCORRUPTED; 111 111 return 0; 112 112 } ··· 130 130 struct xfs_scrub *sc, 131 131 struct xrep_find_ag_btree *fab) 132 132 { 133 - struct xfs_mount *mp = sc->mp; 134 - xfs_agnumber_t agno = sc->sm->sm_agno; 135 - 136 - return xfs_verify_agbno(mp, agno, fab->root) && 133 + return xfs_verify_agbno(sc->sa.pag, fab->root) && 137 134 fab->height <= fab->maxlevels; 138 135 } 139 136
+3 -4
fs/xfs/scrub/alloc.c
··· 93 93 struct xchk_btree *bs, 94 94 const union xfs_btree_rec *rec) 95 95 { 96 - struct xfs_mount *mp = bs->cur->bc_mp; 97 - xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno; 96 + struct xfs_perag *pag = bs->cur->bc_ag.pag; 98 97 xfs_agblock_t bno; 99 98 xfs_extlen_t len; 100 99 ··· 101 102 len = be32_to_cpu(rec->alloc.ar_blockcount); 102 103 103 104 if (bno + len <= bno || 104 - !xfs_verify_agbno(mp, agno, bno) || 105 - !xfs_verify_agbno(mp, agno, bno + len - 1)) 105 + !xfs_verify_agbno(pag, bno) || 106 + !xfs_verify_agbno(pag, bno + len - 1)) 106 107 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 107 108 108 109 xchk_allocbt_xref(bs->sc, bno, len);
+3 -3
fs/xfs/scrub/ialloc.c
··· 104 104 xfs_extlen_t len) 105 105 { 106 106 struct xfs_mount *mp = bs->cur->bc_mp; 107 - xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno; 107 + struct xfs_perag *pag = bs->cur->bc_ag.pag; 108 108 xfs_agblock_t bno; 109 109 110 110 bno = XFS_AGINO_TO_AGBNO(mp, agino); 111 111 if (bno + len <= bno || 112 - !xfs_verify_agbno(mp, agno, bno) || 113 - !xfs_verify_agbno(mp, agno, bno + len - 1)) 112 + !xfs_verify_agbno(pag, bno) || 113 + !xfs_verify_agbno(pag, bno + len - 1)) 114 114 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 115 115 116 116 xchk_iallocbt_chunk_xref(bs->sc, irec, agino, bno, len);
+3 -4
fs/xfs/scrub/refcount.c
··· 332 332 struct xchk_btree *bs, 333 333 const union xfs_btree_rec *rec) 334 334 { 335 - struct xfs_mount *mp = bs->cur->bc_mp; 336 335 xfs_agblock_t *cow_blocks = bs->private; 337 - xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno; 336 + struct xfs_perag *pag = bs->cur->bc_ag.pag; 338 337 xfs_agblock_t bno; 339 338 xfs_extlen_t len; 340 339 xfs_nlink_t refcount; ··· 353 354 /* Check the extent. */ 354 355 bno &= ~XFS_REFC_COW_START; 355 356 if (bno + len <= bno || 356 - !xfs_verify_agbno(mp, agno, bno) || 357 - !xfs_verify_agbno(mp, agno, bno + len - 1)) 357 + !xfs_verify_agbno(pag, bno) || 358 + !xfs_verify_agbno(pag, bno + len - 1)) 358 359 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 359 360 360 361 if (refcount == 0)
+3 -3
fs/xfs/scrub/rmap.c
··· 92 92 { 93 93 struct xfs_mount *mp = bs->cur->bc_mp; 94 94 struct xfs_rmap_irec irec; 95 - xfs_agnumber_t agno = bs->cur->bc_ag.pag->pag_agno; 95 + struct xfs_perag *pag = bs->cur->bc_ag.pag; 96 96 bool non_inode; 97 97 bool is_unwritten; 98 98 bool is_bmbt; ··· 121 121 * Otherwise we must point somewhere past the static metadata 122 122 * but before the end of the FS. Run the regular check. 123 123 */ 124 - if (!xfs_verify_agbno(mp, agno, irec.rm_startblock) || 125 - !xfs_verify_agbno(mp, agno, irec.rm_startblock + 124 + if (!xfs_verify_agbno(pag, irec.rm_startblock) || 125 + !xfs_verify_agbno(pag, irec.rm_startblock + 126 126 irec.rm_blockcount - 1)) 127 127 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 128 128 }
+1 -1
fs/xfs/xfs_fsops.c
··· 132 132 oagcount = mp->m_sb.sb_agcount; 133 133 /* allocate the new per-ag structures */ 134 134 if (nagcount > oagcount) { 135 - error = xfs_initialize_perag(mp, nagcount, &nagimax); 135 + error = xfs_initialize_perag(mp, nagcount, nb, &nagimax); 136 136 if (error) 137 137 return error; 138 138 } else if (nagcount < oagcount) {
+2 -1
fs/xfs/xfs_log_recover.c
··· 3313 3313 /* re-initialise in-core superblock and geometry structures */ 3314 3314 mp->m_features |= xfs_sb_version_to_features(sbp); 3315 3315 xfs_reinit_percpu_counters(mp); 3316 - error = xfs_initialize_perag(mp, sbp->sb_agcount, &mp->m_maxagi); 3316 + error = xfs_initialize_perag(mp, sbp->sb_agcount, sbp->sb_dblocks, 3317 + &mp->m_maxagi); 3317 3318 if (error) { 3318 3319 xfs_warn(mp, "Failed post-recovery per-ag init: %d", error); 3319 3320 return error;
+2 -1
fs/xfs/xfs_mount.c
··· 778 778 /* 779 779 * Allocate and initialize the per-ag data. 780 780 */ 781 - error = xfs_initialize_perag(mp, sbp->sb_agcount, &mp->m_maxagi); 781 + error = xfs_initialize_perag(mp, sbp->sb_agcount, mp->m_sb.sb_dblocks, 782 + &mp->m_maxagi); 782 783 if (error) { 783 784 xfs_warn(mp, "Failed per-ag init: %d", error); 784 785 goto out_free_dir;