Comments (2)
I've removed the open/close/open as I found out it was created by someone before me in the project due to a bug they had elsewhere... (Did you know that some OS'es allow you to free a memory chunk allocated from a memory slab not part of the slab you are free-ing to? This leads to hilarious results, especially if a different thread later receives the chunk as a result of their allocation from the slab!)
Now I just sync() after header to get some ID into the file (inline) in case I need to search for it in the raw blocks later.
from littlefs.
Hmmm, this gets tricky.
The thing we really don't want to do is compact a metadata block that doesn't benefit from compaction (is only a single commit).
The block_size/2
limit is the threshold where we split a metadata block, so after compaction all metadata blocks should fit in block_size/2
. Using this also as the lower-bound for lfs_fs_gc
means that we are always guaranteed to make progress if we attempt a compaction.
Some options:
-
Make the
block_size/2
limit configurable (split_thresh
?).This would let you tweak the worst-case compaction size. Though a lower
split_thresh
would result in more mdirs/lower mdir util. -
Explicitly count the number of commits (we currently don't track this), and allow
compact_thresh < block_size/2
iffcommits > 1
.This would allow opportunistic compactions, but I'm not sure opportunistic compactions are that common when the metadata/block_size ratio isn't so high.
As a workaround, you could also try increasing block_size
. The larger the block_size
, the more space there is for the log to append to. Though I realize this may make other performance issues significantly worse...
This may also be exacerbated by the way I create files as I open+create the file, then close it again and re-open before starting to write.
You can call lfs_file_sync
in this case. It won't save any progs/erases, but it will avoid an extra path lookup.
from littlefs.
Related Issues (20)
- Zephyr OS little FS file system Write timeing issue HOT 1
- corrupted dir pair error after many power losses when underlying mass memory is a SD card HOT 3
- Blocks 0 and 1 becoming corrupted whilst creating just 1 file - Problem confirmed as block count being anything other than 512. HOT 1
- Exposing tracking counters for wear analysis and other performance analysis (erase, write, and read block counters) HOT 1
- Feature Request: Extra programming buffer for metadata or waiting to commit the new file until closed? HOT 7
- data loss in littlefs HOT 2
- Mounting a loop device from c. HOT 1
- LittleFS not truncating previous file content when overwriting a file HOT 1
- lfs_filebd.c seems to assume errno values HOT 2
- Provide a function for probing for LFS HOT 12
- Hardfault in lfs_dir_relocatingcommit, LFS 2.9, LFS_ASSERT(pdir) with pdir null HOT 3
- renaming symbols HOT 5
- pread/pwrite HOT 6
- When are file attributes deleted or not deleted? HOT 3
- Superblock corruption HOT 28
- is it safe to open a file multiple times? HOT 4
- lfs_remove doesn't have unlink/rmdir distinction HOT 4
- When are file attributes finally written to "disk"? HOT 2
- Block count defined twice HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from littlefs.