From 5bfa2a10712081eb785c36d4971b53c672e60ca5 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 12 Oct 2025 14:09:56 -0500 Subject: [PATCH] gbmap: Added an lfs3_alloc_ckpoint to lfs3_fs_mkconsistent lfs3_fs_mkconsistent is already limited to call sites where lfs3_alloc_ckpoint is valid (lfs3_fs_mkconsistent internally relies on lfs3_mdir_commit), so might as well include an unconditional lfs3_alloc_ckpoint to populate allocators and save some code: code stack ctx no-gbmap before: 37168 2352 684 no-gbmap after: 37164 (-0.0%) 2352 (+0.0%) 684 (+0.0%) code stack ctx maybe-gbmap before: 39720 2376 848 maybe-gbmap after: 39708 (-0.0%) 2376 (+0.0%) 848 (+0.0%) code stack ctx yes-gbmap before: 39208 2376 848 yes-gbmap after: 39204 (-0.0%) 2376 (+0.0%) 848 (+0.0%) --- lfs3.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lfs3.c b/lfs3.c index 3b125e7e..93e1386c 100644 --- a/lfs3.c +++ b/lfs3.c @@ -16824,6 +16824,16 @@ int lfs3_fs_mkconsistent(lfs3_t *lfs3) { } } + // go ahead and checkpoint the allocator + // + // this isn't always needed, but redundant alloc ckpoints are noops, + // so might as well to eagerly populate allocators and save some + // code + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + return 0; } #endif @@ -17137,13 +17147,6 @@ int lfs3_fs_mkgbmap(lfs3_t *lfs3) { return err; } - // checkpoint the allocator - // TODO, should lfs3_fs_mkconsistent also checkpoint the allocator? - err = lfs3_alloc_ckpoint(lfs3); - if (err) { - return err; - } - // create an empty gbmap lfs3_gbmap_init(&lfs3->gbmap);