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%)
This commit is contained in:
@@ -11203,7 +11203,6 @@ static lfs3_sblock_t lfs3_alloc_(lfs3_t *lfs3, uint32_t flags,
|
|||||||
if (err) {
|
if (err) {
|
||||||
// bad erase? try another block
|
// bad erase? try another block
|
||||||
if (err == LFS3_ERR_CORRUPT) {
|
if (err == LFS3_ERR_CORRUPT) {
|
||||||
lfs3_alloc_inc(lfs3);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
Reference in New Issue
Block a user