littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
4.92k stars 774 forks source link

Add lfs_fs_gc to enable proactive finding of free blocks #875

Closed geky closed 9 months ago

geky commented 10 months ago

See https://github.com/littlefs-project/littlefs/pull/610 for more info, original PR by @opilat.

This API allows users to run the internal block allocator directly, which may allow users to move the expensive block scan out of performance sensitive parts of their codebase.

It should be noted this API does not current persist the results of the block scan on disk, so calling lfs_fs_gc and then remounting does nothing. This may change in the future.

geky-bot commented 10 months ago
Tests passed ✓, Code: 16710 B (+0.2%), Stack: 1448 B (+1.1%), Structs: 788 B (+0.0%) | | Code | Stack | Structs | | Coverage | |:--|-----:|------:|--------:|:--|---------:| | Default | 16710 B (+0.2%) | 1448 B (+1.1%) | 788 B (+0.0%) | Lines | 2327/2507 lines (+0.0%) | | Readonly | 6126 B (+0.0%) | 448 B (+0.0%) | 788 B (+0.0%) | Branches | 1186/1508 branches (-0.0%) | | Threadsafe | 17562 B (+0.3%) | 1448 B (+1.1%) | 796 B (+0.0%) | | **Benchmarks** | | Multiversion | 16786 B (+0.2%) | 1448 B (+1.1%) | 792 B (+0.0%) | Readed | 29369693876 B (+0.0%) | | Migrate | 18394 B (+0.2%) | 1752 B (+0.9%) | 792 B (+0.0%) | Proged | 1482874766 B (+0.0%) | | Error-asserts | 17342 B (+0.2%) | 1440 B (+1.1%) | 788 B (+0.0%) | Erased | 1568888832 B (+0.0%) |
geky-bot commented 9 months ago
Tests passed ✓, Code: 16838 B (+0.2%), Stack: 1448 B (+1.1%), Structs: 800 B (+0.0%) | | Code | Stack | Structs | | Coverage | |:--|-----:|------:|--------:|:--|---------:| | Default | 16838 B (+0.2%) | 1448 B (+1.1%) | 800 B (+0.0%) | Lines | 2357/2533 lines (+0.1%) | | Readonly | 6130 B (+0.0%) | 448 B (+0.0%) | 800 B (+0.0%) | Branches | 1202/1528 branches (+0.1%) | | Threadsafe | 17722 B (+0.3%) | 1448 B (+1.1%) | 808 B (+0.0%) | | **Benchmarks** | | Multiversion | 16898 B (+0.2%) | 1448 B (+1.1%) | 804 B (+0.0%) | Readed | 29369693876 B (+0.0%) | | Migrate | 18514 B (+0.2%) | 1752 B (+0.9%) | 804 B (+0.0%) | Proged | 1482874766 B (+0.0%) | | Error-asserts | 17498 B (+0.2%) | 1440 B (+1.1%) | 800 B (+0.0%) | Erased | 1568888832 B (+0.0%) |