Make attribute writing be dependent on attr_count upon close/sync and not upon open - #1173
Open
amgross wants to merge 1 commit into
Open
Make attribute writing be dependent on attr_count upon close/sync and not upon open#1173amgross wants to merge 1 commit into
amgross wants to merge 1 commit into
Conversation
Collaborator
Tests passed ✓, Code: 17132 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 812 B (+0.0%)
|
Member
|
Hi @amgross, thanks for creating a PR for this (and for writing tests!) Sorry about the very late response. littlefs2 is currently under a "feature-freeze" to help focus on completing littlefs3 (#1111, unstable), so I appreciate this PR but unfortunately will not be able to review/merge it anytime soon. The attr API is also being reworked in littlefs3, with some plans to adopt I'll try to revisit this when actionable, but in case a forget, feel free to reopen or ping this PR after littlefs3 work lands. |
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.
Current user attributes behavior given upon open to write is bit complicated:
If attribute count is not 0 upon open:
At the first sync (or close) after the open things will be written to the disk (in cost of wear etc.) even if user decided not to write attributes and changed attribute count to 0 (maybe wanted to read attributes upon open and according that decided not to update them?).
at next syncs (or close) will write user attributes will be re-written (and changed if user changed them in the buffer) just if the file changed till then.
If attribute count is 0 upon open:
syncs (or close) user attributes will be re-written (and changed if user changed them in the buffer) just if the file changed till then.
This is complex behave, and in cases for example that user opened file with READ-WRITE and wanted to read attributes it will cause write to flash even if he decided not to change anything.
Solution in this fix
The write of the user attributes will be done if and just if file was opened to write and attribute count is greater than 0 upon the close/sync.
tests that added (and will fail without this PR):