Skip to content

Commit 30bac03

Browse files
DNedickartben
authored andcommitted
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 <[email protected]>
1 parent 2a206a0 commit 30bac03

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

subsys/fs/Kconfig.littlefs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ config FS_LITTLEFS_LOOKAHEAD_SIZE
5656
help
5757
A larger lookahead buffer increases the number of blocks found
5858
during an allocation pass. The lookahead buffer is stored as a
59-
compact bitmap, so each byte of RAM can track 8 blocks. Must
60-
be a multiple of 8.
59+
compact bitmap, so each byte of RAM can track 8 blocks.
6160

6261
config FS_LITTLEFS_BLOCK_CYCLES
6362
int "Number of erase cycles before moving data to another block"

subsys/fs/littlefs_fs.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +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_lookahead_size = block_size * 4;
848-
849847
lcp->read = lfs_api_read_blk;
850848
lcp->prog = lfs_api_prog_blk;
851849
lcp->erase = lfs_api_erase_blk;
@@ -859,12 +857,7 @@ static int littlefs_init_cfg(struct fs_littlefs *fs, int flags)
859857
}
860858
lcp->cache_size = ROUND_DOWN(cache_size, block_size);
861859

862-
if (lookahead_size < new_lookahead_size) {
863-
LOG_ERR("Configured lookahead size is too small: %d < %d",
864-
lookahead_size, new_lookahead_size);
865-
return -ENOMEM;
866-
}
867-
lcp->lookahead_size = new_lookahead_size;
860+
lcp->lookahead_size = lookahead_size;
868861

869862
lcp->sync = lfs_api_sync_blk;
870863

0 commit comments

Comments
 (0)