trv: Adopted LFS3_t_STALE for marking block queue as stale

This solves the previous gc-needs-block-queue-so-we-can-clobber-block-
queue issue by adding an additional LFS3_t_STALE flag to indicate when
any block queues would be invalid.

So instead of clearing block queues in lfs3_alloc_ckpoint, we just set
LFS3_t_STALE, and any lfs3_trv_ts can clear their block queues in
lfs3_trv_read. This allows lfs3_mgc_ts to be allocated without a block
queue when doing any LFS3_M_*/LFS3_F_*/LFS3_GC_* work.

LFS3_t_STALE is set at the same time as LFS3_t_CKPOINT and LFS3_t_DIRTY,
but we need a separate bit so lfs3_trv_read can clear the flag after
flushing without losing ckpoint/dirty information.

---

Unfortunately, none of the stack-allocated lfs3_mgc_ts are on the stack
hot-path, so we don't immediate savings. But note the 2-words saved in
ctx when compiling in LFS3_GC mode:

                 code          stack          ctx
  before:       35940           2280          660
  after:        35944 (+0.0%)   2280 (+0.0%)  660 (+0.0%)

                 code          stack          ctx
  gbmap before: 38916           2296          772
  gbmap after:  38916 (+0.0%)   2296 (+0.0%)  772 (+0.0%)

                 code          stack          ctx
  gc before:    36012           2280          776
  gc after:     36016 (+0.0%)   2280 (+0.0%)  768 (-1.0%)
This commit is contained in:
Christopher Haster
2025-11-08 01:40:01 -06:00
parent d1d69c0a52
commit 14c369af93
4 changed files with 69 additions and 75 deletions
+3 -2
View File
@@ -159,8 +159,9 @@ t_MDIR = 0x00100000 # i^ Btype = mdir
t_BTREE = 0x00200000 # i^ Btype = btree
t_DATA = 0x00300000 # i^ Btype = data
t_ZOMBIE = 0x08000000 # i- File has been removed
t_DIRTY = 0x04000000 # i- Filesystem ckpointed outside traversal
t_CKPOINTED = 0x02000000 # i- Filesystem ckpointed during traversal
t_CKPOINTED = 0x04000000 # i- Filesystem ckpointed during traversal
t_DIRTY = 0x02000000 # i- Filesystem ckpointed outside traversal
t_STALE = 0x01000000 # i- Block queue probably out-of-date
# Block allocator flags
alloc_ERASE = 0x00000001 # i- Please erase the block