On Tue, Oct 12, 2021 at 04:33:28PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > Compute the actual maximum btree height when deciding if 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. And replacing it with a branchy dynamic calculation that has a static, unchanging result. :( > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> > --- > fs/xfs/libxfs/xfs_ag_resv.c | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > > diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c > index 2aa2b3484c28..d34d4614f175 100644 > --- a/fs/xfs/libxfs/xfs_ag_resv.c > +++ b/fs/xfs/libxfs/xfs_ag_resv.c > @@ -60,6 +60,20 @@ > * to use the reservation system should update ask/used in xfs_ag_resv_init. > */ > > +/* Compute maximum possible height for per-AG btree types for this fs. */ > +static unsigned int > +xfs_ag_btree_maxlevels( > + struct xfs_mount *mp) > +{ > + unsigned int ret = mp->m_ag_maxlevels; > + > + ret = max(ret, mp->m_bm_maxlevels[XFS_DATA_FORK]); > + ret = max(ret, mp->m_bm_maxlevels[XFS_ATTR_FORK]); > + ret = max(ret, M_IGEO(mp)->inobt_maxlevels); > + ret = max(ret, mp->m_rmap_maxlevels); > + return max(ret, mp->m_refc_maxlevels); > +} Hmmmm. perhaps mp->m_ag_maxlevels should be renamed to mp->m_agbno_maxlevels and we pre-calculate mp->m_ag_maxlevels from the above function and just use the variable in the xfs_ag_resv_critical() check? Cheers, Dave. -- Dave Chinner david@xxxxxxxxxxxxx