From ced63a4c7398a01276790391ff90cb86279ba58d Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 16 Oct 2025 14:15:45 -0500 Subject: [PATCH] Renamed inline_size -> shrub_size There's a strong argument for naming this inline_size as that's more likely what users expect, but shrub_size is just the more correct name and avoids confusion around having multiple names for the same thing. It also highlights that shrubs in littlefs3 are a bit different than inline files in littlefs2, and that this config also affects large files with a shrubbed root. May rerevert this in the future, but probably only if there is significant user confusion. --- lfs3.c | 24 ++++++++++++------------ lfs3.h | 2 +- runners/bench_runner.h | 4 ++-- runners/test_runner.h | 4 ++-- tests/test_ck.toml | 6 +++--- tests/test_fwrite.toml | 8 ++++---- tests/test_powerloss.toml | 6 +++--- tests/test_trvs.toml | 14 +++++++------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lfs3.c b/lfs3.c index fe94c743..9b27d8a9 100644 --- a/lfs3.c +++ b/lfs3.c @@ -6963,7 +6963,7 @@ static int lfs3_bshrub_commitroot_(lfs3_t *lfs3, lfs3_bshrub_t *bshrub, // // Instead, we keep track of an estimate of how many bytes have // been progged to the shrub since the last estimate, and recalculate - // the estimate when this overflows our inline_size. This mirrors how + // the estimate when this overflows our shrub_size. This mirrors how // block_size and rbyds interact, and amortizes the estimate cost. // figure out how much data this commit progs @@ -6982,29 +6982,29 @@ static int lfs3_bshrub_commitroot_(lfs3_t *lfs3, lfs3_bshrub_t *bshrub, } } - // does our estimate exceed our inline_size? need to recalculate an + // does our estimate exceed our shrub_size? need to recalculate an // accurate estimate lfs3_ssize_t estimate = (lfs3_bshrub_isbshrub(bshrub)) ? bshrub->shrub.r.eoff : (lfs3_size_t)-1; // this double condition avoids overflow issues - if ((lfs3_size_t)estimate > lfs3->cfg->inline_size - || estimate + commit_estimate > lfs3->cfg->inline_size) { + if ((lfs3_size_t)estimate > lfs3->cfg->shrub_size + || estimate + commit_estimate > lfs3->cfg->shrub_size) { estimate = lfs3_bshrub_estimate(lfs3, bshrub); if (estimate < 0) { return estimate; } // two cases where we evict: - // - overflow inline_size/2 - don't penalize for commits here - // - overflow inline_size - must include commits or risk overflow + // - overflow shrub_size/2 - don't penalize for commits here + // - overflow shrub_size - must include commits or risk overflow // // the 1/2 here prevents runaway performance with the shrub is // near full, but it's a heuristic, so including the commit would // just be mean // - if ((lfs3_size_t)estimate > lfs3->cfg->inline_size/2 - || estimate + commit_estimate > lfs3->cfg->inline_size) { + if ((lfs3_size_t)estimate > lfs3->cfg->shrub_size/2 + || estimate + commit_estimate > lfs3->cfg->shrub_size) { return LFS3_ERR_RANGE; } } @@ -12786,7 +12786,7 @@ int lfs3_file_opencfg_(lfs3_t *lfs3, lfs3_file_t *file, // small file wrset? can we atomically commit everything in one // commit? currently this is only possible via lfs3_set if (lfs3_o_iswrset(file->b.h.flags) - && file->cache.size <= lfs3->cfg->inline_size + && file->cache.size <= lfs3->cfg->shrub_size && file->cache.size <= lfs3->cfg->fragment_size && file->cache.size < lfs3_max(lfs3->cfg->crystal_thresh, 1)) { // we need to mark as unsync for sync to do anything @@ -14821,7 +14821,7 @@ int lfs3_file_sync(lfs3_t *lfs3, lfs3_file_t *file) { // if the file is small enough to fit in the cache int err; if (file->cache.size == lfs3_file_size_(file) - && file->cache.size <= lfs3->cfg->inline_size + && file->cache.size <= lfs3->cfg->shrub_size && file->cache.size <= lfs3->cfg->fragment_size && file->cache.size < lfs3_max(lfs3->cfg->crystal_thresh, 1)) { // discard any overwritten leaves, this also clears the @@ -15461,8 +15461,8 @@ static int lfs3_init(lfs3_t *lfs3, uint32_t flags, #endif #ifndef LFS3_RDONLY - // inline_size must be <= block_size/4 - LFS3_ASSERT(lfs3->cfg->inline_size <= lfs3->cfg->block_size/4); + // shrub_size must be <= block_size/4 + LFS3_ASSERT(lfs3->cfg->shrub_size <= lfs3->cfg->block_size/4); // fragment_size must be <= block_size/4 LFS3_ASSERT(lfs3->cfg->fragment_size <= lfs3->cfg->block_size/4); #endif diff --git a/lfs3.h b/lfs3.h index 9bd83470..8c7e0257 100644 --- a/lfs3.h +++ b/lfs3.h @@ -536,7 +536,7 @@ struct lfs3_cfg { // // 0 disables shrubs. #ifndef LFS3_RDONLY - lfs3_size_t inline_size; + lfs3_size_t shrub_size; #endif // Maximum size of a non-block B-tree leaf in bytes. Smaller values may diff --git a/runners/bench_runner.h b/runners/bench_runner.h index 0d8a2e98..149aa750 100644 --- a/runners/bench_runner.h +++ b/runners/bench_runner.h @@ -117,7 +117,7 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size); BENCH_DEFINE(GC_FLAGS, 0 ) \ BENCH_DEFINE(GC_STEPS, 0 ) \ BENCH_DEFINE(GC_COMPACT_THRESH, 0 ) \ - BENCH_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \ + BENCH_DEFINE(SHRUB_SIZE, BLOCK_SIZE/4 ) \ BENCH_DEFINE(FRAGMENT_SIZE, LFS3_MIN(BLOCK_SIZE/8, 512) ) \ BENCH_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 ) \ BENCH_DEFINE(GBMAP_REPOP_THRESH, BLOCK_COUNT/4 ) \ @@ -148,7 +148,7 @@ void bench_permutation(size_t i, uint32_t *buffer, size_t size); BENCH_GBMAP_CFG \ BENCH_GC_CFG \ .gc_compact_thresh = GC_COMPACT_THRESH, \ - .inline_size = INLINE_SIZE, \ + .shrub_size = SHRUB_SIZE, \ .fragment_size = FRAGMENT_SIZE, \ .crystal_thresh = CRYSTAL_THRESH, diff --git a/runners/test_runner.h b/runners/test_runner.h index ca7a64d1..c0a72914 100644 --- a/runners/test_runner.h +++ b/runners/test_runner.h @@ -108,7 +108,7 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size); TEST_DEFINE(GC_FLAGS, 0 ) \ TEST_DEFINE(GC_STEPS, 0 ) \ TEST_DEFINE(GC_COMPACT_THRESH, 0 ) \ - TEST_DEFINE(INLINE_SIZE, BLOCK_SIZE/4 ) \ + TEST_DEFINE(SHRUB_SIZE, BLOCK_SIZE/4 ) \ TEST_DEFINE(FRAGMENT_SIZE, LFS3_MIN(BLOCK_SIZE/8, 512) ) \ TEST_DEFINE(CRYSTAL_THRESH, BLOCK_SIZE/8 ) \ TEST_DEFINE(GBMAP_REPOP_THRESH, BLOCK_COUNT/4 ) \ @@ -139,7 +139,7 @@ void test_permutation(size_t i, uint32_t *buffer, size_t size); TEST_GBMAP_CFG \ TEST_GC_CFG \ .gc_compact_thresh = GC_COMPACT_THRESH, \ - .inline_size = INLINE_SIZE, \ + .shrub_size = SHRUB_SIZE, \ .fragment_size = FRAGMENT_SIZE, \ .crystal_thresh = CRYSTAL_THRESH, diff --git a/tests/test_ck.toml b/tests/test_ck.toml index d9022e58..b5efdf33 100644 --- a/tests/test_ck.toml +++ b/tests/test_ck.toml @@ -1669,7 +1669,7 @@ code = ''' defines.BADBIT = -1 defines.BADBLOCK_BEHAVIOR = 'LFS3_EMUBD_BADBLOCK_PROGFLIP' # force the file to create a btree -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -2179,7 +2179,7 @@ code = ''' [cases.test_ck_ckfetches_btree] defines.BADBIT = -1 # force the file to create a btree -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -2442,7 +2442,7 @@ defines.BADBLOCK_BEHAVIOR = [ 'LFS3_EMUBD_BADBLOCK_READFLIP', ] # force the file to create a btree -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' diff --git a/tests/test_fwrite.toml b/tests/test_fwrite.toml index 4999f308..9f2a934a 100644 --- a/tests/test_fwrite.toml +++ b/tests/test_fwrite.toml @@ -106,7 +106,7 @@ code = ''' defines.N = [0, 1, 2, 3, 4] defines.SIZE = 'N*FRAGMENT_SIZE' # force a btree node -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.SYNC = [false, true] in = 'lfs3.c' @@ -502,7 +502,7 @@ defines.N = [0, 1, 2, 3, 4] defines.SIZE = 'N*FRAGMENT_SIZE' defines.CHUNK = [32, 8, 1] # force a btree node -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.SYNC = [false, true] defines.REMOUNT = [false, true] @@ -2432,7 +2432,7 @@ defines.N = [0, 1, 2, 3, 4] defines.SIZE = 'N*FRAGMENT_SIZE' defines.CHUNK = [32, 8, 1] # force a btree node -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.SYNC = [false, true] defines.REMOUNT = [false, true] @@ -2884,7 +2884,7 @@ defines.N = [0, 1, 2, 3, 4] defines.SIZE = 'N*FRAGMENT_SIZE' defines.CHUNK = [32, 8, 1] # force a btree node -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.SYNC = [false, true] defines.REMOUNT = [false, true] diff --git a/tests/test_powerloss.toml b/tests/test_powerloss.toml index abf15cb0..f6ca2a8f 100644 --- a/tests/test_powerloss.toml +++ b/tests/test_powerloss.toml @@ -128,7 +128,7 @@ defines.POWERLOSS_BEHAVIOR = [ ] defines.MKCONSISTENT = [false, true] # inlining has a tendency to hide sync issues, so try without -defines.INLINE_SIZE = ['BLOCK_SIZE/4', '0'] +defines.SHRUB_SIZE = ['BLOCK_SIZE/4', '0'] defines.N = [1, 2, 4, 8, 16, 32, 64] defines.SIZE = [ '0', @@ -228,7 +228,7 @@ defines.POWERLOSS_BEHAVIOR = [ ] defines.MKCONSISTENT = [false, true] # inlining has a tendency to hide sync issues, so try without -defines.INLINE_SIZE = ['BLOCK_SIZE/4', '0'] +defines.SHRUB_SIZE = ['BLOCK_SIZE/4', '0'] defines.N = [1, 2, 4, 8, 16, 32, 64] defines.OPS = 256 defines.SIZE = [ @@ -459,7 +459,7 @@ defines.POWERLOSS_BEHAVIOR = [ ] defines.MKCONSISTENT = [false, true] # inlining has a tendency to hide sync issues, so try without -defines.INLINE_SIZE = ['BLOCK_SIZE/4', '0'] +defines.SHRUB_SIZE = ['BLOCK_SIZE/4', '0'] # note dirs x files grows O(n^2) defines.N = [1, 2, 4, 8] defines.M = 'N' diff --git a/tests/test_trvs.toml b/tests/test_trvs.toml index abefc4c5..a114a184 100644 --- a/tests/test_trvs.toml +++ b/tests/test_trvs.toml @@ -2487,7 +2487,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] defines.SIZE = '2*BLOCK_SIZE' -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.TRUNC = [false, true] code = ''' lfs3_t lfs3; @@ -2805,7 +2805,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] defines.SIZE = '2*BLOCK_SIZE' -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 code = ''' lfs3_t lfs3; lfs3_format(&lfs3, @@ -3134,7 +3134,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] defines.SIZE = '2*BLOCK_SIZE' -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.DESYNC = [false, true] code = ''' lfs3_t lfs3; @@ -7263,7 +7263,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] # limit files to very simple btrees -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -7439,7 +7439,7 @@ defines.LOOKAHEAD = [false, true] defines.CKMETA = [false, true] defines.CKDATA = [false, true] # limit files to very simple btrees -defines.INLINE_SIZE = 0 +defines.SHRUB_SIZE = 0 defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = '2*FRAGMENT_SIZE' @@ -7616,7 +7616,7 @@ defines.CKMETA = [false, true] defines.CKDATA = [false, true] # this configuration should create a 2-layer bshrub, which may be # a bit delicate -defines.INLINE_SIZE = 'BLOCK_SIZE/4' +defines.SHRUB_SIZE = 'BLOCK_SIZE/4' defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = 'BLOCK_SIZE' @@ -7801,7 +7801,7 @@ defines.CKMETA = [false, true] defines.CKDATA = [false, true] # this configuration should create a 2-layer bshrub, which may be # a bit delicate -defines.INLINE_SIZE = 'BLOCK_SIZE/4' +defines.SHRUB_SIZE = 'BLOCK_SIZE/4' defines.CRYSTAL_THRESH = -1 defines.FRAGMENT_SIZE = 'BLOCK_SIZE/8' defines.SIZE = 'BLOCK_SIZE'