gbmap: Renamed gbmap_scan_thresh -> gbmap_rebuild_thresh

I think a good rule of thumb is if you refer to some variable/config/
field with a different name in comments/writing/etc more often than not,
you should just rename the variable/config/field to match.

So yeah, gbmap_rebuild_thresh controls when the gbmap is rebuilt.

Also touched up the doc comment a bit.
This commit is contained in:
Christopher Haster
2025-10-07 00:05:33 -05:00
parent ea05ad04b9
commit cb9bda5a94
4 changed files with 100 additions and 99 deletions
+1 -1
View File
@@ -10973,7 +10973,7 @@ static inline int lfs3_alloc_ckpoint(lfs3_t *lfs3) {
// do we need to rebuild the gbmap?
if (lfs3_f_isgbmap(lfs3->flags)
&& lfs3->lookahead.gbmapped < lfs3_min(
lfs3->cfg->gbmap_scan_thresh,
lfs3->cfg->gbmap_rebuild_thresh,
lfs3->block_count)) {
int err = lfs3_alloc_rebuildgbmap(lfs3);
if (err) {
+7 -6
View File
@@ -546,15 +546,16 @@ struct lfs3_cfg {
lfs3_size_t crystal_thresh;
#endif
// Threshold for when to rebuild block-map information. littlefs
// will attempt to rebuild the block-map when fewer than this many
// blocks are known. Larger values rebuild the block-map more
// Threshold for when to rebuild the global on-disk block-map (gbmap).
// littlefs will attempt to rebuild the gbmap when fewer than this
// many blocks are known. Larger values rebuild the gbmap more
// frequently, reducing the chance of falling back to a slower
// allocator at a performance cost.
// allocator at the cost of amortized allocator throughput.
//
// 0 only rebuilds the block-map when empty.
// 0 only rebuilds the gbmap when empty, but note rebuilding the
// gbmap may require allocating blocks.
#ifdef LFS3_GBMAP
lfs3_block_t gbmap_scan_thresh;
lfs3_block_t gbmap_rebuild_thresh;
#endif
};
+2 -2
View File
@@ -120,7 +120,7 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size);
BENCH_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \
BENCH_DEFINE(FRAGMENT_SIZE, LFS3_MIN(BLOCK_SIZE/8, 512) ) \
BENCH_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 ) \
BENCH_DEFINE(GBMAP_SCAN_THRESH, BLOCK_COUNT/4 ) \
BENCH_DEFINE(GBMAP_REBUILD_THRESH, BLOCK_COUNT/4 ) \
BENCH_DEFINE(ERASE_VALUE, 0xff ) \
BENCH_DEFINE(ERASE_CYCLES, 0 ) \
BENCH_DEFINE(BADBLOCK_BEHAVIOR, LFS3_EMUBD_BADBLOCK_PROGERROR ) \
@@ -154,7 +154,7 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size);
#ifdef LFS3_GBMAP
#define BENCH_GBMAP_CFG \
.gbmap_scan_thresh = GBMAP_SCAN_THRESH,
.gbmap_rebuild_thresh = GBMAP_REBUILD_THRESH,
#else
#define BENCH_GBMAP_CFG
#endif
+2 -2
View File
@@ -111,7 +111,7 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size);
TEST_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \
TEST_DEFINE(FRAGMENT_SIZE, LFS3_MIN(BLOCK_SIZE/8, 512) ) \
TEST_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 ) \
TEST_DEFINE(GBMAP_SCAN_THRESH, BLOCK_COUNT/4 ) \
TEST_DEFINE(GBMAP_REBUILD_THRESH, BLOCK_COUNT/4 ) \
TEST_DEFINE(ERASE_VALUE, 0xff ) \
TEST_DEFINE(ERASE_CYCLES, 0 ) \
TEST_DEFINE(BADBLOCK_BEHAVIOR, LFS3_EMUBD_BADBLOCK_PROGERROR ) \
@@ -145,7 +145,7 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size);
#ifdef LFS3_GBMAP
#define TEST_GBMAP_CFG \
.gbmap_scan_thresh = GBMAP_SCAN_THRESH,
.gbmap_rebuild_thresh = GBMAP_REBUILD_THRESH,
#else
#define TEST_GBMAP_CFG
#endif