fs/littlefs: improve littlefs flash block erase balance performance

This commit is contained in:
mi 2021-08-12 15:17:01 +08:00 committed by Xiang Xiao
parent 5b350f3a0f
commit 21316466d2
2 changed files with 20 additions and 4 deletions

View File

@ -3,4 +3,18 @@ config FS_LITTLEFS
default n
depends on !DISABLE_MOUNTPOINT
---help---
Build the LITTLEFS file system. https://github.com/ARMmbed/littlefs.
Build the LITTLEFS file system. https://github.com/littlefs-project/littlefs.
if FS_LITTLEFS
config FS_LITTLEFS_BLOCK_FACTOR
int "LITTLEFS Block size multiple factor"
default 4
---help---
Configure the cache size of the LITTLEFS file system with a multiple factor of the block size.
config FS_LITTLEFS_BLOCK_CYCLE
int "LITTLEFS Block Cycle"
default 200
---help---
Configure the block cycle of the LITTLEFS file system.
endif

View File

@ -1019,12 +1019,14 @@ static int littlefs_bind(FAR struct inode *driver, FAR const void *data,
fs->cfg.prog = littlefs_write_block;
fs->cfg.erase = littlefs_erase_block;
fs->cfg.sync = littlefs_sync_block;
fs->cfg.read_size = fs->geo.blocksize;
fs->cfg.read_size = fs->geo.blocksize *
CONFIG_FS_LITTLEFS_BLOCK_FACTOR;
fs->cfg.prog_size = fs->geo.blocksize;
fs->cfg.block_size = fs->geo.erasesize;
fs->cfg.block_count = fs->geo.neraseblocks;
fs->cfg.block_cycles = 500;
fs->cfg.cache_size = fs->geo.blocksize;
fs->cfg.block_cycles = CONFIG_FS_LITTLEFS_BLOCK_CYCLE;
fs->cfg.cache_size = fs->geo.blocksize *
CONFIG_FS_LITTLEFS_BLOCK_FACTOR;
fs->cfg.lookahead_size = lfs_min(lfs_alignup(fs->cfg.block_count, 64) / 8,
fs->cfg.read_size);