Skip to content

Commit 36029de

Browse files
dgchinnerdchinner
authored andcommitted
xfs: make is_log_ag() a first class helper
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>
1 parent 3829c9a commit 36029de

8 files changed

Lines changed: 18 additions & 17 deletions

File tree

fs/xfs/libxfs/xfs_ag.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,6 @@ xfs_get_aghdr_buf(
390390
return 0;
391391
}
392392

393-
static inline bool is_log_ag(struct xfs_mount *mp, struct aghdr_init_data *id)
394-
{
395-
return mp->m_sb.sb_logstart > 0 &&
396-
id->agno == XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart);
397-
}
398-
399393
/*
400394
* Generic btree root block init function
401395
*/
@@ -421,7 +415,7 @@ xfs_freesp_init_recs(
421415
arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1);
422416
arec->ar_startblock = cpu_to_be32(mp->m_ag_prealloc_blocks);
423417

424-
if (is_log_ag(mp, id)) {
418+
if (xfs_ag_contains_log(mp, id->agno)) {
425419
struct xfs_alloc_rec *nrec;
426420
xfs_agblock_t start = XFS_FSB_TO_AGBNO(mp,
427421
mp->m_sb.sb_logstart);
@@ -548,7 +542,7 @@ xfs_rmaproot_init(
548542
}
549543

550544
/* account for the log space */
551-
if (is_log_ag(mp, id)) {
545+
if (xfs_ag_contains_log(mp, id->agno)) {
552546
rrec = XFS_RMAP_REC_ADDR(block,
553547
be16_to_cpu(block->bb_numrecs) + 1);
554548
rrec->rm_startblock = cpu_to_be32(
@@ -619,7 +613,7 @@ xfs_agfblock_init(
619613
agf->agf_refcount_blocks = cpu_to_be32(1);
620614
}
621615

622-
if (is_log_ag(mp, id)) {
616+
if (xfs_ag_contains_log(mp, id->agno)) {
623617
int64_t logblocks = mp->m_sb.sb_logblocks;
624618

625619
be32_add_cpu(&agf->agf_freeblks, -logblocks);

fs/xfs/libxfs/xfs_ag.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ xfs_verify_agino_or_null(struct xfs_perag *pag, xfs_agino_t agino)
165165
return xfs_verify_agino(pag, agino);
166166
}
167167

168+
static inline bool
169+
xfs_ag_contains_log(struct xfs_mount *mp, xfs_agnumber_t agno)
170+
{
171+
return mp->m_sb.sb_logstart > 0 &&
172+
agno == XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart);
173+
}
174+
168175
/*
169176
* Perag iteration APIs
170177
*/

fs/xfs/libxfs/xfs_ialloc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,8 +2897,7 @@ xfs_ialloc_calc_rootino(
28972897
* allocation group, or very odd geometries created by old mkfs
28982898
* versions on very small filesystems.
28992899
*/
2900-
if (mp->m_sb.sb_logstart &&
2901-
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == 0)
2900+
if (xfs_ag_contains_log(mp, 0))
29022901
first_bno += mp->m_sb.sb_logblocks;
29032902

29042903
/*

fs/xfs/libxfs/xfs_ialloc_btree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,7 @@ xfs_inobt_max_size(
697697
* never be available for the kinds of things that would require btree
698698
* expansion. We therefore can pretend the space isn't there.
699699
*/
700-
if (mp->m_sb.sb_logstart &&
701-
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
700+
if (xfs_ag_contains_log(mp, pag->pag_agno))
702701
agblocks -= mp->m_sb.sb_logblocks;
703702

704703
return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr,

fs/xfs/libxfs/xfs_refcount_btree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,7 @@ xfs_refcountbt_calc_reserves(
507507
* never be available for the kinds of things that would require btree
508508
* expansion. We therefore can pretend the space isn't there.
509509
*/
510-
if (mp->m_sb.sb_logstart &&
511-
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
510+
if (xfs_ag_contains_log(mp, pag->pag_agno))
512511
agblocks -= mp->m_sb.sb_logblocks;
513512

514513
*ask += xfs_refcountbt_max_size(mp, agblocks);

fs/xfs/libxfs/xfs_rmap_btree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,8 +666,7 @@ xfs_rmapbt_calc_reserves(
666666
* never be available for the kinds of things that would require btree
667667
* expansion. We therefore can pretend the space isn't there.
668668
*/
669-
if (mp->m_sb.sb_logstart &&
670-
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
669+
if (xfs_ag_contains_log(mp, pag->pag_agno))
671670
agblocks -= mp->m_sb.sb_logblocks;
672671

673672
/* Reserve 1% of the AG or enough for 1 block per record. */

fs/xfs/scrub/health.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "xfs_shared.h"
99
#include "xfs_format.h"
1010
#include "xfs_btree.h"
11+
#include "xfs_trans_resv.h"
12+
#include "xfs_mount.h"
1113
#include "xfs_ag.h"
1214
#include "xfs_health.h"
1315
#include "scrub/scrub.h"

fs/xfs/scrub/refcount.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "scrub/scrub.h"
1414
#include "scrub/common.h"
1515
#include "scrub/btree.h"
16+
#include "xfs_trans_resv.h"
17+
#include "xfs_mount.h"
1618
#include "xfs_ag.h"
1719

1820
/*

0 commit comments

Comments
 (0)