From 530ff95178b24848498a70e25017896a3c90b173 Mon Sep 17 00:00:00 2001 From: geky-bot Date: Thu, 21 Dec 2023 06:59:41 +0000 Subject: [PATCH] Squashed 'littlefs/' changes from c733d9e..3513ff1 3513ff1 Merge pull request #911 from littlefs-project/fix-release-structs 8a22bd6 Merge pull request #910 from littlefs-project/fix-superblock-expansion-thresh 9b82db7 Merge pull request #898 from zchen24/patch-1 99b84ee Update DESIGN.md, fix minor typo e91a29d Fixed struct sizes missing from generated release notes b9b95ab Increase threshold for superblock expansion from ~50% -> ~88% full 10bcff1 Update DESIGN.md minor typo git-subtree-dir: littlefs git-subtree-split: 3513ff1afc1d67adb2e6f492f0b9bc0d798fcb0d --- .github/workflows/release.yml | 2 +- DESIGN.md | 4 ++-- lfs.c | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61b2972..5ccc9e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -112,7 +112,7 @@ jobs: table[$i,$j]=$c_camel ((j+=1)) - for s in code stack struct + for s in code stack structs do f=sizes/thumb${c:+-$c}.$s.csv [ -e $f ] && table[$i,$j]=$( \ diff --git a/DESIGN.md b/DESIGN.md index 1d02ba3..9c9703a 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -59,7 +59,7 @@ This leaves us with three major requirements for an embedded filesystem. RAM to temporarily store filesystem metadata. For ROM, this means we need to keep our design simple and reuse code paths - were possible. For RAM we have a stronger requirement, all RAM usage is + where possible. For RAM we have a stronger requirement, all RAM usage is bounded. This means RAM usage does not grow as the filesystem changes in size or number of files. This creates a unique challenge as even presumably simple operations, such as traversing the filesystem, become surprisingly @@ -626,7 +626,7 @@ log₂_n_ pointers that skip to different preceding elements of the skip-list. The name comes from heavy use of the [CTZ instruction][wikipedia-ctz], which -lets us calculate the power-of-two factors efficiently. For a give block _n_, +lets us calculate the power-of-two factors efficiently. For a given block _n_, that block contains ctz(_n_)+1 pointers. ``` diff --git a/lfs.c b/lfs.c index aed1b07..a152687 100644 --- a/lfs.c +++ b/lfs.c @@ -2151,9 +2151,11 @@ static int lfs_dir_splittingcompact(lfs_t *lfs, lfs_mdir_t *dir, return size; } - // do we have extra space? littlefs can't reclaim this space - // by itself, so expand cautiously - if ((lfs_size_t)size < lfs->block_count/2) { + // littlefs cannot reclaim expanded superblocks, so expand cautiously + // + // if our filesystem is more than ~88% full, don't expand, this is + // somewhat arbitrary + if (lfs->block_count - size > lfs->block_count/8) { LFS_DEBUG("Expanding superblock at rev %"PRIu32, dir->rev); int err = lfs_dir_split(lfs, dir, attrs, attrcount, source, begin, end);