Skip to content

Commit 2a206a0

Browse files
DNedickartben
authored andcommitted
fs: littlefs: Improve block device cache size
Instead of picking a set of safe block multiple sized values for caches, round down to the nearest block multiple, increasing static buffer usage determined by Kconfig variables. Signed-off-by: Djordje Nedic <[email protected]>
1 parent fb53ea0 commit 2a206a0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

subsys/fs/littlefs_fs.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,6 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
844844
lcp->context = fs->backend;
845845
/* Set the validated/defaulted values. */
846846
if (littlefs_on_blkdev(flags)) {
847-
lfs_size_t new_cache_size = block_size;
848847
lfs_size_t new_lookahead_size = block_size * 4;
849848

850849
lcp->read = lfs_api_read_blk;
@@ -854,12 +853,11 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
854853
lcp->read_size = block_size;
855854
lcp->prog_size = block_size;
856855

857-
if (cache_size < new_cache_size) {
856+
if (cache_size < block_size) {
858857
LOG_ERR("Configured cache size is too small: %d < %d", cache_size,
859-
new_cache_size);
860-
return -ENOMEM;
858+
block_size);
861859
}
862-
lcp->cache_size = new_cache_size;
860+
lcp->cache_size = ROUND_DOWN(cache_size, block_size);
863861

864862
if (lookahead_size < new_lookahead_size) {
865863
LOG_ERR("Configured lookahead size is too small: %d < %d",

0 commit comments

Comments
 (0)