diff options
author | Will <will@mon.im> | 2020-12-15 05:59:32 +0300 |
---|---|---|
committer | Will <will@mon.im> | 2020-12-15 05:59:32 +0300 |
commit | 6b16dafb4db903fc1f8509d4170af56ae70ee56e (patch) | |
tree | fc05969c787306c350a241cc8821d741278365f5 /lfs.h | |
parent | 1a59954ec64ca168828a15242cc6de94ac75f9d1 (diff) |
Add metadata_max and inline_file_max to config
We have seen poor read performance on NAND flashes with 128kB blocks.
The root cause is inline files having to traverse many sets of metadata
pairs inside the current block before being fully reconstructed. Simply
disabling inline files is not enough, as the metadata will still fill up
the block and eventually need to be compacted.
By allowing configuration of how much size metadata takes up, along with
limiting (or disabling) inline file size, we achieve read performance
improvements on an order of magnitude.
Diffstat (limited to 'lfs.h')
-rw-r--r-- | lfs.h | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -207,7 +207,7 @@ struct lfs_config { // Number of erasable blocks on the device. lfs_size_t block_count; - // Number of erase cycles before littlefs evicts metadata logs and moves + // Number of erase cycles before littlefs evicts metadata logs and moves // the metadata to another block. Suggested values are in the // range 100-1000, with large values having better performance at the cost // of less consistent wear distribution. @@ -256,6 +256,20 @@ struct lfs_config { // larger attributes size but must be <= LFS_ATTR_MAX. Defaults to // LFS_ATTR_MAX when zero. lfs_size_t attr_max; + + // Optional upper limit on total space given to metadata pairs in bytes. On + // devices with large blocks (e.g. 128kB) setting this to a low size (2-8kB) + // can help bound the metadata compaction time. Must be <= block_size. + // Defaults to block_size when zero. + lfs_size_t metadata_max; + + // Optional upper limit on inline files in bytes. On devices with large + // blocks (e.g. 128kB) setting this to a low size or disabling inline files + // can help bound file read overhead. Must be <= LFS_FILE_MAX. Defaults to + // block_size/8 when zero. + // + // Set to -1 to disable inline files. + lfs_ssize_t inline_file_max; }; // File info structure @@ -406,6 +420,8 @@ typedef struct lfs { lfs_size_t name_max; lfs_size_t file_max; lfs_size_t attr_max; + lfs_size_t metadata_max; + lfs_ssize_t inline_file_max; #ifdef LFS_MIGRATE struct lfs1 *lfs1; |