Skip to content

Commit b74e15d

Browse files
author
Darrick J. Wong
committed
xfs: compute maximum AG btree height for critical reservation calculation
Compute the actual maximum AG btree height for deciding if a per-AG block reservation is critically low. This only affects the sanity check condition, since we /generally/ will trigger on the 10% threshold. This is a long-winded way of saying that we're removing one more usage of XFS_BTREE_MAXLEVELS. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 7cb3efb commit b74e15d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

fs/xfs/libxfs/xfs_ag_resv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ xfs_ag_resv_critical(
9191
trace_xfs_ag_resv_critical(pag, type, avail);
9292

9393
/* Critically low if less than 10% or max btree height remains. */
94-
return XFS_TEST_ERROR(avail < orig / 10 || avail < XFS_BTREE_MAXLEVELS,
94+
return XFS_TEST_ERROR(avail < orig / 10 ||
95+
avail < pag->pag_mount->m_agbtree_maxlevels,
9596
pag->pag_mount, XFS_ERRTAG_AG_RESV_CRITICAL);
9697
}
9798

fs/xfs/xfs_mount.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,18 @@ xfs_mount_setup_inode_geom(
567567
xfs_ialloc_setup_geometry(mp);
568568
}
569569

570+
/* Compute maximum possible height for per-AG btree types for this fs. */
571+
static inline void
572+
xfs_agbtree_compute_maxlevels(
573+
struct xfs_mount *mp)
574+
{
575+
unsigned int levels;
576+
577+
levels = max(mp->m_alloc_maxlevels, M_IGEO(mp)->inobt_maxlevels);
578+
levels = max(levels, mp->m_rmap_maxlevels);
579+
mp->m_agbtree_maxlevels = max(levels, mp->m_refc_maxlevels);
580+
}
581+
570582
/*
571583
* This function does the following on an initial mount of a file system:
572584
* - reads the superblock from disk and init the mount struct
@@ -638,6 +650,8 @@ xfs_mountfs(
638650
xfs_rmapbt_compute_maxlevels(mp);
639651
xfs_refcountbt_compute_maxlevels(mp);
640652

653+
xfs_agbtree_compute_maxlevels(mp);
654+
641655
/*
642656
* Check if sb_agblocks is aligned at stripe boundary. If sb_agblocks
643657
* is NOT aligned turn off m_dalign since allocator alignment is within

fs/xfs/xfs_mount.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ typedef struct xfs_mount {
132132
uint m_bm_maxlevels[2]; /* max bmap btree levels */
133133
uint m_rmap_maxlevels; /* max rmap btree levels */
134134
uint m_refc_maxlevels; /* max refcount btree level */
135+
unsigned int m_agbtree_maxlevels; /* max level of all AG btrees */
135136
xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */
136137
uint m_alloc_set_aside; /* space we can't use */
137138
uint m_ag_max_usable; /* max space per AG */

0 commit comments

Comments
 (0)