From 51fa5b983151ed535ec7aee21ddc538c50eb3593 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 19 Jul 2024 02:49:57 -0500 Subject: [PATCH] gc: Reverted to only consider ckmeta/ckdata done if not mutated Two main reasons: 1. If we mount without ckprogs, we do actually have a pretty decent hole here where data can be written with errors and go unchecked during lfsr_fs_gc. 2. If we're traversing a btree that gets mutated mid-traversal, we're kicked entirely off the btree. This means we could miss large ranges of btree nodes/data blocks that may not have themselves been mutated. Not great. Worst case, it doesn't hurt to check things again if the filesystem changes. If this is too much of a bottleneck, you should probably be running gc in incremental mode anyways, which always starts a new traversal on ckmeta/ckdata. Checking for dirty/mutated doesn't really add that much code: code stack before: 36240 2680 after: 36256 (+0.0%) 2680 (+0.0%) --- lfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lfs.c b/lfs.c index 6248cbb3..2bc89056 100644 --- a/lfs.c +++ b/lfs.c @@ -13129,10 +13129,12 @@ int lfsr_fs_gc(lfs_t *lfs, lfs_soff_t steps, uint32_t flags) { | ((!lfsr_i_isuncompacted(lfs->flags)) ? LFS_GC_COMPACT : 0) - // consider our filesystem checked if we complete at - // least one traversal - | LFS_GC_CKMETA - | LFS_GC_CKDATA); + // only consider our filesystem checked if we + // weren't mutated + | ((!lfsr_f_isdirty(lfs->gc.o.o.flags) + && !lfsr_f_ismutated(lfs->gc.o.o.flags)) + ? LFS_GC_CKMETA | LFS_GC_CKDATA + : 0)); } // decrement steps