I am using littlefs to store logs to internal flash and have been testing the behaviour when the littlefs partition is full. I expected a graceful failure of fopen() or fprintf() but I get a DivideByZero exception from lfs_alloc in the bowels of the library from fclose(). It seems that I need to leave 8K of unused space to avoid this. Am I missing some config?
ESP-IDF v5.1.2
litlefs v1.14.2
littlefs panic when partition is full
-
- Posts: 50
- Joined: Thu Jun 22, 2023 12:50 pm
Re: littlefs panic when partition is full
Thank you for the report. We will investigate this. However it may be an issue on the LittleFS side. If so we will notify the maintainers.
Re: littlefs panic when partition is full
@owenjames can you post the full log? I believe this is an upstream core littlefs issue (unexpected divide by zero); esp_littlefs should be reporting an appropriate error code. The log can help us raise an appropriate issue in https://github.com/littlefs-project/littlefs
Re: littlefs panic when partition is full
Sorry, I don't have the log now but my notes show the exception occurs in lfs.c (when block_count is zero):
- static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
- ...
- // In order to keep our block allocator from spinning forever when our
- // filesystem is full, we mark points where there are no in-flight
- // allocations with a checkpoint before starting a set of allocations.
- //
- // If we've looked at all blocks since the last checkpoint, we report
- // the filesystem as out of storage.
- //
- if (lfs->lookahead.ckpoint <= 0) {
- LFS_ERROR("No more free space 0x%"PRIx32,
- (lfs->lookahead.start + lfs->lookahead.next)
- % lfs->cfg->block_count);
- return LFS_ERR_NOSPC;
- }
Re: littlefs panic when partition is full
In this context, is the number of blocks in the entire filesystem, not free ones remaining. In newer versions of littlefs, the value can be set to 0 to be inferred from an existing filesystem; on mount is then appropriately populated.
If you can get a fullstack trace, or other info, it would greatly help! Upstream littlefs does have exhaustion tests, and I cannot find a location by inspection where a DivideByZero could occur. Thanks!
Also, I just released esp_littlefs v1.14.3 that updates littlefs v2.9.0 to v2.9.1, incase that fixes anything.
Code: Select all
block_count
Code: Select all
lfs_config.block_count
Code: Select all
lfs.block_count
If you can get a fullstack trace, or other info, it would greatly help! Upstream littlefs does have exhaustion tests, and I cannot find a location by inspection where a DivideByZero could occur. Thanks!
Also, I just released esp_littlefs v1.14.3 that updates littlefs v2.9.0 to v2.9.1, incase that fixes anything.
Re: littlefs panic when partition is full
Based on huming2207 being able to reproduce it here: https://github.com/joltwallet/esp_littlefs/issues/183
I opened up a PR that may resolve the issue here: https://github.com/littlefs-project/littlefs/pull/966
Will update when it gets merged and and makes its way to esp_littlefs.
I opened up a PR that may resolve the issue here: https://github.com/littlefs-project/littlefs/pull/966
Will update when it gets merged and and makes its way to esp_littlefs.
Re: littlefs panic when partition is full
fixed in core littlefs v2.9.2, and subsequently in esp_littlefs v1.14.4
Who is online
Users browsing this forum: No registered users and 57 guests