Bump default inline_max up to 1/4 block size

As noted by amgross, the current inline_max default (when littlefs
switches from inline files to CTZ skip-lists) does not match the
theoretical value in DESIGN.md.

The reason for this is 1/8 was chosen as a safer default during
development, due to concerns that 1/4 + mdirs splitting at 1/2 would
lead to poor distribution of large inline files in mdirs.

However, two things have happened since then:

1. Experiments have show "wasted" mdir space is less of a concern than
   initially thought. Extra mdir space contributes to logging, delays
   mdir compaction, and can overall lead to better performance.

2. inline_size was added as a configuration option, so if 1/4 is
   problematic users can always override it.

So bumping this back up to 1/4 may make sense.
This commit is contained in:
Christopher Haster 2025-09-29 13:49:58 -05:00
parent 8e251dd675
commit ab59ab7f8d
2 changed files with 3 additions and 3 deletions

4
lfs.c
View File

@ -4331,7 +4331,7 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
LFS_ASSERT(lfs->cfg->inline_max == (lfs_size_t)-1
|| lfs->cfg->inline_max <= ((lfs->cfg->metadata_max)
? lfs->cfg->metadata_max
: lfs->cfg->block_size)/8);
: lfs->cfg->block_size)/4);
lfs->inline_max = lfs->cfg->inline_max;
if (lfs->inline_max == (lfs_size_t)-1) {
lfs->inline_max = 0;
@ -4342,7 +4342,7 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
lfs->attr_max,
((lfs->cfg->metadata_max)
? lfs->cfg->metadata_max
: lfs->cfg->block_size)/8));
: lfs->cfg->block_size)/4));
}
// setup default state

2
lfs.h
View File

@ -277,7 +277,7 @@ struct lfs_config {
// Optional upper limit on inlined files in bytes. Inlined files live in
// metadata and decrease storage requirements, but may be limited to
// improve metadata-related performance. Must be <= cache_size, <=
// attr_max, and <= block_size/8. Defaults to the largest possible
// attr_max, and <= block_size/4. Defaults to the largest possible
// inline_max when zero.
//
// Set to -1 to disable inlined files.