-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal Assert Triggered When Removing File After Filesystem is Full #1080
Comments
Hi @pasvensson, thanks for creating an issue and test case. This is unfortunately expected. If LittleFS fills up completely, it can become "stuck", where it is impossible for the filesystem to allocate a block to make forward progress. This is a fundamental problem for copy-on-write filesystems. Eventually it would be nice to solve this by reserving some number of blocks are "emergency" operations, but this is tricky because 1. LittleFS is on devices with large variety of block_counts, and 2. knowing exactly how many blocks are free is surprisingly tricky internally. In the meantime, it's up to users to avoid completely filling the filesystem. Either via application specific knowledge, or by checking |
Fortunately for me (not OP), this is not likely in my current use case. But this seems unfortunate in general.
Is an
This may be worth documenting? |
So, it's technically not an assert that's being hit first. In the above test case, This is a bit of a separate problem, but LFS_ERR_NOSPC is one of the "anywhere" errors that littlefs currently can't fully recover from (the others being LFS_ERR_CORRUPT, LFS_ERR_IO, etc). The result is broken in-RAM state that ends up asserting. I've been looking into rewriting littlefs to handling these "anywhere" errors robustly, but it will probably add a ~1.5-2x stack cost since you need to keep track of both the before/after states until the metadata commits succeed (or fail). Still, I think ultimately this RAM cost is necessary for correct/safe behavior by default. I'm currently rolling it up into the other big obnoxious snowball of changes (rbyd), since it requires more-or-less a full rewrite. Maybe in the future we can also add a sort of "LFS_GLASS" mode for users that want the reduced code/RAM cost with the tradeoff of unrecoverable errors, but it's low priority.
It's interesting how rare this has actually been a problem for most embedded use cases. I guess most embedded applications simply try to the avoid the ENOSPC condition, since it usually indicates a throughput issue. But I agree it's unfortunate. It's extra frustrating in that I don't think a rigorous solution is possible, instead this will probably always rely on a heuristic of some sort (preconfigured number of reserved blocks).
Agree, but one question is where? Maybe in |
If the way (a way) to avoid it is "by checking |
Hi,
I'm encountering an issue with LittleFS where an internal assert is triggered when attempting to remove a file after the filesystem has been reported as full. This problem occurs consistently and prevents further file operations. Perhaps I'm missing to do something. Is there any way to prevent this from happening?
Steps to Reproduce:
Expected Behavior:
The file should be removed without triggering an internal assert.
Actual Behavior:
An internal assert is triggered, preventing the file from being removed.
Environment:
Running a test in the littlefs test environment
Log
Here are the last few lines of output from the test I'm running:
References:
The littlefs fork & branch: https://github.com/pasvensson/littlefs/tree/exhaustion_repeat
The test case: tests/test_exhaustion_repeat.toml
The text was updated successfully, but these errors were encountered: