BLS: suggest fixed-width boot counters for atomic updates on FAT32 #168
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.
This PR extends the "Boot counting" section to specify that boot counter fields should be fixed-width and pre-initialized, in order to keep rename operations atomic on FAT32 filesystems.
On FAT32, long filenames are implemented as a series of consecutive LFN entries. When the filename length changes (e.g. when adding the "tries done" suffix), the filesystem may need to reallocate directory entries and move existing ones around. This can require rewriting multiple sectors and is not guaranteed to be atomic. In worst case, a power loss during such an operation could leave partial LFN chains or break other directory entries.
By requiring fixed-width counters and pre-initializing the "tries-done" field, we can ensure that boot counter updates do not change the filename length, and thus avoid triggering potentially non-atomic operations.
Obviously this would be a breaking change in the spec, so it might be more appropriate to phrase this as a recommendation rather than a requirement. I'd love some input on which of the two directions would be preferable, and I'm happy to reword this if the more suggestion-based approach is considered better.