Skip to content

Commit cc601d9

Browse files
committed
Merge: xfs: fix internal error from AGFL exhaustion
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/3674 JIRA: https://issues.redhat.com/browse/RHEL-22150 Signed-off-by: Pavel Reichl <preichl@redhat.com> Approved-by: Andrey Albershteyn <aalbersh@redhat.com> Approved-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Scott Weaver <scweaver@redhat.com>
2 parents 3004c59 + b7a057d commit cc601d9

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,16 +2206,37 @@ xfs_alloc_min_freelist(
22062206

22072207
ASSERT(mp->m_alloc_maxlevels > 0);
22082208

2209+
/*
2210+
* For a btree shorter than the maximum height, the worst case is that
2211+
* every level gets split and a new level is added, then while inserting
2212+
* another entry to refill the AGFL, every level under the old root gets
2213+
* split again. This is:
2214+
*
2215+
* (full height split reservation) + (AGFL refill split height)
2216+
* = (current height + 1) + (current height - 1)
2217+
* = (new height) + (new height - 2)
2218+
* = 2 * new height - 2
2219+
*
2220+
* For a btree of maximum height, the worst case is that every level
2221+
* under the root gets split, then while inserting another entry to
2222+
* refill the AGFL, every level under the root gets split again. This is
2223+
* also:
2224+
*
2225+
* 2 * (current height - 1)
2226+
* = 2 * (new height - 1)
2227+
* = 2 * new height - 2
2228+
*/
2229+
22092230
/* space needed by-bno freespace btree */
22102231
min_free = min_t(unsigned int, levels[XFS_BTNUM_BNOi] + 1,
2211-
mp->m_alloc_maxlevels);
2232+
mp->m_alloc_maxlevels) * 2 - 2;
22122233
/* space needed by-size freespace btree */
22132234
min_free += min_t(unsigned int, levels[XFS_BTNUM_CNTi] + 1,
2214-
mp->m_alloc_maxlevels);
2235+
mp->m_alloc_maxlevels) * 2 - 2;
22152236
/* space needed reverse mapping used space btree */
22162237
if (xfs_has_rmapbt(mp))
22172238
min_free += min_t(unsigned int, levels[XFS_BTNUM_RMAPi] + 1,
2218-
mp->m_rmap_maxlevels);
2239+
mp->m_rmap_maxlevels) * 2 - 2;
22192240

22202241
return min_free;
22212242
}

0 commit comments

Comments
 (0)