From 3659a5c8c4fdb4b93b88e6d80aa7b6c1af749788 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 30 Dec 2025 02:08:23 -0600 Subject: [PATCH] alloc: Fixed double alloc on bad erases Whoops, looks like the lfs3_alloc refactoring resulted in us calling lfs3_alloc_inc multiple times. In effect allocating multiple blocks when triggered, wasting erased-state and lookahead scans. The good(?) news is this was only triggered when we failed to erase a block, which made it difficult for our tests to catch. --- Saves a bit of code when we don't do unnecessary work: code stack ctx before: 35152 2136 660 after: 35144 (-0.0%) 2136 (+0.0%) 660 (+0.0%) code stack ctx gbmap before: 38392 2144 776 gbmap after: 38384 (-0.0%) 2144 (+0.0%) 776 (+0.0%) code stack ctx preerase before: 38928 2168 796 preerase after: 38924 (-0.0%) 2168 (+0.0%) 796 (+0.0%) --- lfs3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lfs3.c b/lfs3.c index 150fdc86..c89e4419 100644 --- a/lfs3.c +++ b/lfs3.c @@ -11203,7 +11203,6 @@ static lfs3_sblock_t lfs3_alloc_(lfs3_t *lfs3, uint32_t flags, if (err) { // bad erase? try another block if (err == LFS3_ERR_CORRUPT) { - lfs3_alloc_inc(lfs3); continue; } return err;