Skip to content

Commit

Permalink
Merge pull request #910 from littlefs-project/fix-superblock-expansio…
Browse files Browse the repository at this point in the history
…n-thresh

Increase threshold for superblock expansion from ~50% -> ~88% full
  • Loading branch information
geky authored Dec 21, 2023
2 parents 9b82db7 + b9b95ab commit 8a22bd6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8a22bd6

Please sign in to comment.