From 54ecc94702c69fea36894b038e74467de4a5a758 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 16 Jul 2024 19:22:42 -0500 Subject: [PATCH] Moved lfs_alloc_ckpoint out of lfsr_mtree_gc Matching lfsr_mdir_commit, it's probably safer if lfs_alloc_ckpoint calls are always explicit. This is doubly true for traversals since we absolutely must not call lfs_alloc_ckpoint in lfsr_mtree_traverse, or else lfs_alloc will break in a really comical fashion. It's also a bit silly how little an impact on code size this had: before: 36472 2680 after: 36476 (-0.0%) 2680 (+0.0%) --- lfs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lfs.c b/lfs.c index a4cdb5c2..2cc867b8 100644 --- a/lfs.c +++ b/lfs.c @@ -8701,9 +8701,6 @@ static int lfsr_mtree_gc(lfs_t *lfs, lfsr_traversal_t *t, // swap dirty/mutated flags while in lfsr_mtree_gc t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags); - // checkpoint the allocator to maximize any lookahead scans - lfs_alloc_ckpoint(lfs); - dropped:; lfsr_tag_t tag; lfsr_bptr_t bptr; @@ -12692,6 +12689,9 @@ int lfsr_mount(lfs_t *lfs, uint32_t flags, || (lfsr_t_isckdata(flags) && mutated)) { + // checkpoint the allocator to maximize any lookahead scans + lfs_alloc_ckpoint(lfs); + // do we really need a full traversal? uint32_t flags_ = flags; if (!((lfsr_t_islookahead(flags) @@ -13124,6 +13124,9 @@ int lfsr_fs_gc(lfs_t *lfs, uint32_t flags) { return 0; } + // checkpoint the allocator to maximize any lookahead scans + lfs_alloc_ckpoint(lfs); + // do we really need a full traversal? if (!((lfsr_t_islookahead(flags) && lfsr_fs_canlookahead(lfs)) @@ -13298,6 +13301,9 @@ int lfsr_traversal_read(lfs_t *lfs, lfsr_traversal_t *t, t->o.o.flags = lfsr_f_swapdirty(t->o.o.flags); } + // checkpoint the allocator to maximize any lookahead scans + lfs_alloc_ckpoint(lfs); + while (true) { // some redund blocks left over? if (t->blocks[0] != -1) {