Skip to content

Commit 5cd213b

Browse files
committed
xfs: don't reserve per-AG space for an internal log
It turns out that the log can consume nearly all the space in an AG, and when this happens this it's possible that there will be less free space in the AG than the reservation would try to hide. On a debug kernel this can trigger an ASSERT in xfs/250: XFS: Assertion failed: xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved + xfs_perag_resv(pag, XFS_AG_RESV_RMAPBT)->ar_reserved <= pag->pagf_freeblks + pag->pagf_flcount, file: fs/xfs/libxfs/xfs_ag_resv.c, line: 319 The log is permanently allocated, so we know we're never going to have to expand the btrees to hold any records associated with the log space. We therefore can treat the space as if it doesn't exist. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Eric Sandeen <[email protected]>
1 parent a188339 commit 5cd213b

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

fs/xfs/libxfs/xfs_ialloc_btree.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,15 @@ xfs_inobt_max_size(
549549
if (mp->m_inobt_mxr[0] == 0)
550550
return 0;
551551

552+
/*
553+
* The log is permanently allocated, so the space it occupies will
554+
* never be available for the kinds of things that would require btree
555+
* expansion. We therefore can pretend the space isn't there.
556+
*/
557+
if (mp->m_sb.sb_logstart &&
558+
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno)
559+
agblocks -= mp->m_sb.sb_logblocks;
560+
552561
return xfs_btree_calc_size(mp->m_inobt_mnr,
553562
(uint64_t)agblocks * mp->m_sb.sb_inopblock /
554563
XFS_INODES_PER_CHUNK);

fs/xfs/libxfs/xfs_refcount_btree.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,15 @@ xfs_refcountbt_calc_reserves(
427427
tree_len = be32_to_cpu(agf->agf_refcount_blocks);
428428
xfs_trans_brelse(tp, agbp);
429429

430+
/*
431+
* The log is permanently allocated, so the space it occupies will
432+
* never be available for the kinds of things that would require btree
433+
* expansion. We therefore can pretend the space isn't there.
434+
*/
435+
if (mp->m_sb.sb_logstart &&
436+
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno)
437+
agblocks -= mp->m_sb.sb_logblocks;
438+
430439
*ask += xfs_refcountbt_max_size(mp, agblocks);
431440
*used += tree_len;
432441

fs/xfs/libxfs/xfs_rmap_btree.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,15 @@ xfs_rmapbt_calc_reserves(
578578
tree_len = be32_to_cpu(agf->agf_rmap_blocks);
579579
xfs_trans_brelse(tp, agbp);
580580

581+
/*
582+
* The log is permanently allocated, so the space it occupies will
583+
* never be available for the kinds of things that would require btree
584+
* expansion. We therefore can pretend the space isn't there.
585+
*/
586+
if (mp->m_sb.sb_logstart &&
587+
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno)
588+
agblocks -= mp->m_sb.sb_logblocks;
589+
581590
/* Reserve 1% of the AG or enough for 1 block per record. */
582591
*ask += max(agblocks / 100, xfs_rmapbt_max_size(mp, agblocks));
583592
*used += tree_len;

0 commit comments

Comments
 (0)