Skip to content

Commit 3829c9a

Browse files
dgchinnerdchinner
authored andcommitted
xfs: replace xfs_ag_block_count() with perag accesses
Many of the places that call xfs_ag_block_count() have a perag available. These places can just read pag->block_count directly instead of calculating the AG block count from first principles. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
1 parent 2d6ca83 commit 3829c9a

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

fs/xfs/libxfs/xfs_ialloc_btree.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,10 @@ xfs_inobt_rec_check_count(
683683

684684
static xfs_extlen_t
685685
xfs_inobt_max_size(
686-
struct xfs_mount *mp,
687-
xfs_agnumber_t agno)
686+
struct xfs_perag *pag)
688687
{
689-
xfs_agblock_t agblocks = xfs_ag_block_count(mp, agno);
688+
struct xfs_mount *mp = pag->pag_mount;
689+
xfs_agblock_t agblocks = pag->block_count;
690690

691691
/* Bail out if we're uninitialized, which can happen in mkfs. */
692692
if (M_IGEO(mp)->inobt_mxr[0] == 0)
@@ -698,7 +698,7 @@ xfs_inobt_max_size(
698698
* expansion. We therefore can pretend the space isn't there.
699699
*/
700700
if (mp->m_sb.sb_logstart &&
701-
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno)
701+
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
702702
agblocks -= mp->m_sb.sb_logblocks;
703703

704704
return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr,
@@ -800,7 +800,7 @@ xfs_finobt_calc_reserves(
800800
if (error)
801801
return error;
802802

803-
*ask += xfs_inobt_max_size(mp, pag->pag_agno);
803+
*ask += xfs_inobt_max_size(pag);
804804
*used += tree_len;
805805
return 0;
806806
}

fs/xfs/scrub/agheader_repair.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ xrep_agf_init_header(
198198
agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
199199
agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION);
200200
agf->agf_seqno = cpu_to_be32(sc->sa.pag->pag_agno);
201-
agf->agf_length = cpu_to_be32(xfs_ag_block_count(mp,
202-
sc->sa.pag->pag_agno));
201+
agf->agf_length = cpu_to_be32(sc->sa.pag->block_count);
203202
agf->agf_flfirst = old_agf->agf_flfirst;
204203
agf->agf_fllast = old_agf->agf_fllast;
205204
agf->agf_flcount = old_agf->agf_flcount;
@@ -777,8 +776,7 @@ xrep_agi_init_header(
777776
agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
778777
agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION);
779778
agi->agi_seqno = cpu_to_be32(sc->sa.pag->pag_agno);
780-
agi->agi_length = cpu_to_be32(xfs_ag_block_count(mp,
781-
sc->sa.pag->pag_agno));
779+
agi->agi_length = cpu_to_be32(sc->sa.pag->block_count);
782780
agi->agi_newino = cpu_to_be32(NULLAGINO);
783781
agi->agi_dirino = cpu_to_be32(NULLAGINO);
784782
if (xfs_has_crc(mp))

fs/xfs/scrub/repair.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ xrep_calc_ag_resblks(
209209
/* Now grab the block counters from the AGF. */
210210
error = xfs_alloc_read_agf(pag, NULL, 0, &bp);
211211
if (error) {
212-
aglen = xfs_ag_block_count(mp, sm->sm_agno);
212+
aglen = pag->block_count;
213213
freelen = aglen;
214214
usedlen = aglen;
215215
} else {
@@ -226,16 +226,16 @@ xrep_calc_ag_resblks(
226226
!xfs_verify_agino(pag, icount)) {
227227
icount = pag->agino_max - pag->agino_min + 1;
228228
}
229-
xfs_perag_put(pag);
230229

231230
/* If the block counts are impossible, make worst-case assumptions. */
232231
if (aglen == NULLAGBLOCK ||
233-
aglen != xfs_ag_block_count(mp, sm->sm_agno) ||
232+
aglen != pag->block_count ||
234233
freelen >= aglen) {
235-
aglen = xfs_ag_block_count(mp, sm->sm_agno);
234+
aglen = pag->block_count;
236235
freelen = aglen;
237236
usedlen = aglen;
238237
}
238+
xfs_perag_put(pag);
239239

240240
trace_xrep_calc_ag_resblks(mp, sm->sm_agno, icount, aglen,
241241
freelen, usedlen);

0 commit comments

Comments
 (0)