Commit 30bac038 authored by Djordje Nedic's avatar Djordje Nedic Committed by Benjamin Cabé
Browse files

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: default avatarDjordje Nedic <nedic.djordje2@gmail.com>
parent 2a206a07
Loading
Loading
Loading
Loading
+1 −2
Changes for subsys/fs/Kconfig.littlefs: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -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"
+1 −8
Changes for subsys/fs/littlefs_fs.c: 1 added line, 8 removed lines.
Original line number Diff line number Diff line
@@ -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;