From 10bcff1af867ec9c86ca3a7d91f54305221ff840 Mon Sep 17 00:00:00 2001 From: Zihan Chen Date: Sun, 26 Nov 2023 11:10:24 -0800 Subject: [PATCH 1/4] Update DESIGN.md minor typo --- DESIGN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESIGN.md b/DESIGN.md index 1d02ba3b..0242a370 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 From b9b95ab4bc9479bcd6370e82c55a236325a02026 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 19 Dec 2023 16:35:09 -0600 Subject: [PATCH 2/4] Increase threshold for superblock expansion from ~50% -> ~88% full Superblock expansion is an irreversible operation. In an effort to prevent superblock expansion from claiming valuable scratch space (important for small, <~8 block filesystems), littlefs prevents superblock expansion when the disk is "mostly full". In true computer-scientist fashion, this "mostly full" threshold was set to ~50%. As pointed out by gbolgradov and rojer, >~50% utilization is not uncommon, and it can lead to a situation where superblock expansion does not occur in a relatively healthy filesystem, causing focused wear at the root. To remedy this, the threshold is now increased to ~88% (7/8) full. This may change in the future and should probably be eventually user configurable. Found by gbolgradov and rojer --- lfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lfs.c b/lfs.c index aed1b072..a152687f 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); From e91a29d2b5d107c2bf61c46bbf359dcc889d0946 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Tue, 19 Dec 2023 22:00:18 -0600 Subject: [PATCH 3/4] Fixed struct sizes missing from generated release notes This script was missed during a struct -> structs naming change --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61b29721..5ccc9e05 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]=$( \ From 99b84ee3db9ff1af25fe7194079b312e3a76ca61 Mon Sep 17 00:00:00 2001 From: Zihan Chen Date: Mon, 27 Nov 2023 15:47:54 +0800 Subject: [PATCH 4/4] Update DESIGN.md, fix minor typo --- DESIGN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESIGN.md b/DESIGN.md index 0242a370..9c9703a6 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -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. ```