alloc: Merged LOOKAHEAD+LOOKGBMAP -> single LOOKAHEAD flag

Our flag space is already really packed, and I'm not sure having these
as separate flags is meaningful or useful for users. They both indicate
to repopulate allocators, and most users probably won't care that there
are two subtly different allocators operating under the hood.

There's an argument that LOOKAHEAD not touching disk is a useful
distinction, but in practice you really only need LOOKAHEAD work when
mounted RDWR.

So, merged the behaviors of LOOKAHEAD + LOOKGBMAP such that
LFS3_*_LOOKAHEAD requests repopulation of all allocators based on
gc_lookahead_thresh and gc_lookgbmap_thresh.

In priority order (some notes below):

1. If max(lookahead, gbmap) < gc_lookahead_thresh => repop lookahead
2. If gbmap < gc_lookgbmap_thresh                 => repop gbmap

As a plus, this makes it easier to avoid LFS3_IFDEF_GBMAP mess.

---

It's interesting to note LFS3_*_LOOKAHEAD will still repopulate the
lookahead buffer when the gbmap is present, but only if this would gain
more knowledge than was is currently in the gbmap.

I considered disabling lookahead scans completely when we have a gbmap,
but repopulating the lookahead buffer is still useful if the gbmap is at
risk of exhaustion. This is what gc_lookahead_thresh is for anyways, and
users can set gc_lookahead_thresh=0 if they want to disable this
behavior.

Relatedly, lookahead scans are actually prioritized over gbmap scans
(when they would gain knowledge). In theory this minimizes gc latency,
as gbmap scans risk triggering a full lookahead scan when building the
new gbmap.

---

Code changes minimal:

                 code          stack          ctx
  before:       35152           2136          660
  after:        35152 (+0.0%)   2136 (+0.0%)  660 (+0.0%)

                 code          stack          ctx
  gbmap before: 38076           2136          776
  gbmap after:  38080 (+0.0%)   2136 (+0.0%)  776 (+0.0%)
This commit is contained in:
Christopher Haster
2025-12-04 16:47:22 -06:00
parent ee50dc5307
commit ffc565508a
6 changed files with 411 additions and 603 deletions
-6
View File
@@ -83,7 +83,6 @@ F_CKDATACKSUMS = 0x01000000 # y- Check data checksums on reads
F_MKCONSISTENT = 0x00000800 # y- Make the filesystem consistent
F_LOOKAHEAD = 0x00001000 # y- Repopulate lookahead buffer
F_LOOKGBMAP = 0x00002000 # y- Repopulate the gbmap
F_COMPACTMETA = 0x00008000 # y- Compact metadata logs
F_CKMETA = 0x00010000 # y- Check metadata checksums
F_CKDATA = 0x00020000 # y- Check metadata + data checksums
@@ -103,7 +102,6 @@ M_CKDATACKSUMS = 0x01000000 # y- Check data checksums on reads
M_MKCONSISTENT = 0x00000800 # y- Make the filesystem consistent
M_LOOKAHEAD = 0x00001000 # y- Repopulate lookahead buffer
M_LOOKGBMAP = 0x00002000 # y- Repopulate the gbmap
M_COMPACTMETA = 0x00008000 # y- Compact metadata logs
M_CKMETA = 0x00010000 # y- Check metadata checksums
M_CKDATA = 0x00020000 # y- Check metadata + data checksums
@@ -111,7 +109,6 @@ M_CKDATA = 0x00020000 # y- Check metadata + data checksums
# File/filesystem check flags
CK_MKCONSISTENT = 0x00000800 # -- Make the filesystem consistent
CK_LOOKAHEAD = 0x00001000 # -- Repopulate lookahead buffer
CK_LOOKGBMAP = 0x00002000 # -- Repopulate the gbmap
CK_COMPACTMETA = 0x00008000 # -- Compact metadata logs
CK_CKMETA = 0x00010000 # -- Check metadata checksums
CK_CKDATA = 0x00020000 # -- Check metadata + data checksums
@@ -119,7 +116,6 @@ CK_CKDATA = 0x00020000 # -- Check metadata + data checksums
# GC flags
GC_MKCONSISTENT = 0x00000800 # -- Make the filesystem consistent
GC_LOOKAHEAD = 0x00001000 # -- Repopulate lookahead buffer
GC_LOOKGBMAP = 0x00002000 # -- Repopulate the gbmap
GC_COMPACTMETA = 0x00008000 # -- Compact metadata logs
GC_CKMETA = 0x00010000 # -- Check metadata checksums
GC_CKDATA = 0x00020000 # -- Check metadata + data checksums
@@ -139,7 +135,6 @@ I_CKDATACKSUMS = 0x01000000 # -- Mounted with LFS3_M_CKDATACKSUMS
I_MKCONSISTENT = 0x00000800 # -- Filesystem needs mkconsistent to write
I_LOOKAHEAD = 0x00001000 # -- Lookahead buffer is not full
I_LOOKGBMAP = 0x00002000 # -- The gbmap is not full
I_COMPACTMETA = 0x00008000 # -- Filesystem may have uncompacted metadata
I_CKMETA = 0x00010000 # -- Metadata checksums not checked recently
I_CKDATA = 0x00020000 # -- Data checksums not checked recently
@@ -152,7 +147,6 @@ T_MTREEONLY = 0x00000002 # -- Only traverse the mtree
T_EXCL = 0x00000008 # -- Error if filesystem modified
T_MKCONSISTENT = 0x00000800 # -- Make the filesystem consistent
T_LOOKAHEAD = 0x00001000 # -- Repopulate lookahead buffer
T_LOOKGBMAP = 0x00002000 # -- Repopulate the gbmap
T_COMPACTMETA = 0x00008000 # -- Compact metadata logs
T_CKMETA = 0x00010000 # -- Check metadata checksums
T_CKDATA = 0x00020000 # -- Check metadata + data checksums