Minor optimizations, safety fixes for corrupted filesystems, and doc updates#247
Closed
Chamath-Adithya wants to merge 17 commits into
Closed
Conversation
…8 in LfnBuffer::as_str
Member
|
I looked at a couple at random and I’m not convinced these are useful. Please don’t drop 17 commits on us without discussing the fixes first, eg in the form of an issue. If you used an LLM to generate these then I refer you to the CONTRIBUTING file. |
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.
Description
This PR provides a collection of performance micro-optimizations, safety improvements for corrupted filesystems, and minor documentation updates.
All changes are strictly
no_stdandno_alloccompatible.What's Changed
Division/Modulo Removal in FAT Traversals
% Block::LEN_U32and/ Block::LEN_U32) with fast bitwise masking (& (Block::LEN_U32 - 1)i.e.,& 511) and bit shifts (>> 9).next_cluster,find_next_free_cluster,update_fat).Unsafe Block Reductions
unsafe { open_files.push_unchecked(...) }inVolumeManagerwith safe checked pushes. Since we already perform boundary/capacity checks immediately before pushing, theunsafeblock was redundant.unsafefrom_utf8_uncheckedinLfnBuffer::as_strwithcore::str::from_utf8. Since the internal buffer only accumulates valid UTF-8, this is a zero-cost safety improvement.Robustness Against Corrupted Media/CSDs
bytes_per_clustercalculations withchecked_multo protect against corrupted volume geometries.saturating_sub(2)to prevent subtraction underflows in debug builds when encountering corrupted/invalid cluster indexes< 2.parse_volumefor root directories by validatingblocks_per_cluster != 0.Testing
LfnBufferboundary and empty buffer handling.Documentation
alloc_clusterexplaining FAT traversal/zeroing mechanics.VolumeManager.All 45 tests build and pass cleanly.