Tweaked lfsr_fs_gc to imply LFS_GC_MTREEONLY based on flags
LFS_GC_MTREEONLY is a rather niche/littlefs-specific flag, and we
probably shouldn't expect users to know when to use it. So now we
automatically switch to LFS_GC_MTREEONLY mode in lfsr_fs_gc if it is
sufficient for accomplishing all pending gc work.
Though currently the only traversal that can be LFS_GC_MTREEONLY is
LFS_GC_MKCONSISTENT...
Note that LFS_GC_MTREEONLY can still be explicitly provided, as it does
change the behavior of LFS_GC_COMPACT and LFS_GC_CKMETA (and combining
LFS_GC_MTREEONLY with LFS_GC_LOOKAHEAD/LFS_GC_CKDATA still asserts).
This adds a bit of code:
code stack
before: 35728 2672
after: 35740 (+0.0%) 2672 (+0.0%)
This commit is contained in:
@@ -12895,13 +12895,21 @@ int lfsr_fs_gc(lfs_t *lfs, uint32_t flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// do we really need a full traversal?
|
||||
if (!(lfsr_t_islookahead(flags)
|
||||
|| lfsr_t_iscompact(flags)
|
||||
|| lfsr_t_isckmeta(flags)
|
||||
|| lfsr_t_isckdata(flags))) {
|
||||
flags |= LFS_GC_MTREEONLY;
|
||||
}
|
||||
|
||||
// existing traversal?
|
||||
if (lfsr_omdir_isopen(lfs, &lfs->gc.o.o)) {
|
||||
// note that we mask out flags! if you change flags mid-traversal,
|
||||
// the result is equivalent to the worst-case set of flags
|
||||
// note that we mask flags (except mtreeonly)! if you change flags
|
||||
// mid-traversal, the result is equivalent to the worst-case set
|
||||
// of flags
|
||||
lfs->gc.o.o.flags &= (
|
||||
~LFS_GC_MTREEONLY
|
||||
& ~LFS_GC_MKCONSISTENT
|
||||
~LFS_GC_MKCONSISTENT
|
||||
& ~LFS_GC_LOOKAHEAD
|
||||
& ~LFS_GC_COMPACT
|
||||
& ~LFS_GC_CKMETA
|
||||
|
||||
Reference in New Issue
Block a user