Conversation
There was a problem hiding this comment.
Pull request overview
Updates the LittleFS test esp_littlefs_info returns used_bytes > total_bytes to avoid an infinite loop when the filesystem recovers internally from NOSPC and stdio calls don’t return errors, by adding a secondary “disk full” detection based on used_bytes no longer increasing.
Changes:
- Add tracking (
prev_used/stall_count) to break out of the fill loop whenused_bytesstops growing for 10 iterations. - Hoist
total/useddeclarations outside the loop and reset them each iteration before callingesp_littlefs_info.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix infinite loop in "used_bytes > total_bytes" test
When the filesystem is nearly full, littlefs internally recovers from
NOSPCduring metadata directory splits by falling back to in-place compaction (lfs_dir_splittingcompact). This meansfwrite/fclosenever return errors even though the allocator logs "No more free space" — the operation actually succeeds.The test relied on I/O errors to exit its fill loop. This has broken before (ESP-IDF v5.0 changed stdio buffering so
fwritestopped failing; fixed by also checkingfclose). Now neither fails.Fix: detect disk-full by stopping once
used_bytesfromesp_littlefs_infostops growing for 10 consecutive iterations. Theused <= totalinvariant is still checked every iteration.