fs: littlefs: Fix lookahead buffer sizing

The lookahead buffer is a bitmap containing info on free blocks and does
not have a minimum size or an alignment requirement.

This fixes the arbitrary 4 * block_size requirement for block devices
and fixes Kconfig documentation to remove a reference to nonexistent
8 byte alignment requirement.

Signed-off-by: Djordje Nedic <nedic.djordje2@gmail.com>
This commit is contained in:
Djordje Nedic 2025-01-03 16:22:05 +01:00 committed by Benjamin Cabé
parent 2a206a07b3
commit 30bac038fa
2 changed files with 2 additions and 10 deletions

View File

@ -56,8 +56,7 @@ config FS_LITTLEFS_LOOKAHEAD_SIZE
help
A larger lookahead buffer increases the number of blocks found
during an allocation pass. The lookahead buffer is stored as a
compact bitmap, so each byte of RAM can track 8 blocks. Must
be a multiple of 8.
compact bitmap, so each byte of RAM can track 8 blocks.
config FS_LITTLEFS_BLOCK_CYCLES
int "Number of erase cycles before moving data to another block"

View File

@ -844,8 +844,6 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
lcp->context = fs->backend;
/* Set the validated/defaulted values. */
if (littlefs_on_blkdev(flags)) {
lfs_size_t new_lookahead_size = block_size * 4;
lcp->read = lfs_api_read_blk;
lcp->prog = lfs_api_prog_blk;
lcp->erase = lfs_api_erase_blk;
@ -859,12 +857,7 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
}
lcp->cache_size = ROUND_DOWN(cache_size, block_size);
if (lookahead_size < new_lookahead_size) {
LOG_ERR("Configured lookahead size is too small: %d < %d",
lookahead_size, new_lookahead_size);
return -ENOMEM;
}
lcp->lookahead_size = new_lookahead_size;
lcp->lookahead_size = lookahead_size;
lcp->sync = lfs_api_sync_blk;