gc: Added more tests over info flags, dropped gc_flags default

Since we dropped lfsr_gc_setflags/setsteps, it was no longer possible to
set gc_flags to zero (perfectly valid and useful for system bringup/
testing things). Supporting gc_flags=0 means it's not possible to
provide a default, but this is probably ok as users need to opt-in to
LFS_GC anyways.

Note that at least gc_steps=0 doesn't make sense, so the default there
is reasonable.

Fixing this also highlighted that gc_flags/steps are no longer mutable,
making the comment in lfs_init out-of-date. Dropping these saves a bit
of lfs_t size, so that's nice.

And then testing also revealed that LFS_GC_CKDATA implying LFS_GC_CKDATA
means it should probably clear the LFS_I_CKMETA flag as well.

---

And here I thought this was going to be just a simple test-writing
exercise!

Code changes:

                   code          stack          ctx
  default before: 37792           2608          620
  default after:  37792 (-0.0%)   2608 (+0.0%)  620 (+0.0%)

  gc before:      37896           2608          768
  gc after:       37848 (-0.1%)   2608 (+0.0%)  760 (-1.0%)
This commit is contained in:
Christopher Haster
2025-01-08 16:02:36 -06:00
parent bb4e6cca2c
commit 9ed9cf0ccd
5 changed files with 600 additions and 55 deletions
+8 -4
View File
@@ -71,7 +71,8 @@ code = '''
| ((!MKCONSISTENT) ? LFS_I_MKCONSISTENT : 0)
| ((!LOOKAHEAD) ? LFS_I_LOOKAHEAD : 0)
| ((!COMPACT) ? LFS_I_COMPACT : 0)
| ((!CKMETA) ? LFS_I_CKMETA : 0)
// note ckdata implies ckmeta
| ((!CKMETA && !CKDATA) ? LFS_I_CKMETA : 0)
| ((!CKDATA) ? LFS_I_CKDATA : 0)));
lfsr_unmount(&lfs) => 0;
@@ -144,7 +145,8 @@ code = '''
assert(fsinfo.flags == (
LFS_I_MKCONSISTENT
| LFS_I_COMPACT
| ((!CKMETA) ? LFS_I_CKMETA : 0)
// note ckdata implies ckmeta
| ((!CKMETA && !CKDATA) ? LFS_I_CKMETA : 0)
| ((!CKDATA) ? LFS_I_CKDATA : 0)));
lfsr_unmount(&lfs) => 0;
'''
@@ -215,7 +217,8 @@ code = '''
assert(fsinfo.flags == (
LFS_I_MKCONSISTENT
| ((!LOOKAHEAD) ? LFS_I_LOOKAHEAD : 0)
| ((!CKMETA) ? LFS_I_CKMETA : 0)
// note ckdata implies ckmeta
| ((!CKMETA && !CKDATA) ? LFS_I_CKMETA : 0)
| ((!CKDATA) ? LFS_I_CKDATA : 0)));
// mdir should have been compacted
@@ -314,7 +317,8 @@ code = '''
assert(fsinfo.flags == (
((!LOOKAHEAD) ? LFS_I_LOOKAHEAD : 0)
| ((!COMPACT) ? LFS_I_COMPACT : 0)
| ((!CKMETA) ? LFS_I_CKMETA : 0)
// note ckdata implies ckmeta
| ((!CKMETA && !CKDATA) ? LFS_I_CKMETA : 0)
| ((!CKDATA) ? LFS_I_CKDATA : 0)));
// check we can still read the files