Added some comments over lfs_config's fragment_size/crystal_thresh/etc

Also added related asserts to lfs_init.

Note the fragment_size <= block_size/8 limit is to avoid wasteful corner
cases where only one fragment can fit in a block. The shrub_size <=
block_size/4 limit is looser because of how shrubs temporarily
overcommit.

As for the other limits, inline_size is bounded by shrub_size, and
crystal_thresh technically doesn't have a limit, though values >
block_size stop having an effect.
This commit is contained in:
Christopher Haster
2024-05-13 21:49:25 -05:00
parent a9f6b6e903
commit f5beacf6ee
4 changed files with 33 additions and 3 deletions
+6
View File
@@ -15227,6 +15227,12 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
// wear-leveling.
LFS_ASSERT(lfs->cfg->block_cycles != 0);
// inline_size must be <= block_size/4
LFS_ASSERT(lfs->cfg->inline_size <= lfs->cfg->block_size/4);
// shrub_size must be <= block_size/4
LFS_ASSERT(lfs->cfg->shrub_size <= lfs->cfg->block_size/4);
// fragment_size must be <= block_size/8
LFS_ASSERT(lfs->cfg->fragment_size <= lfs->cfg->block_size/8);
// setup read cache
lfs->rcache.block = 0;