Rework directory block enumeration accounting - #97
Open
RoyWFHuang wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
__file_lookup() and simplefs_remove_from_dir() bound their block walks differently, and neither skips directory blocks that hold no files. Bound both inner loops by nr_bi_files and by the extent length, decrement the count only after a block is scanned, and skip blocks whose nr_files is zero. Bound the outer loops by SIMPLEFS_MAX_EXTENTS the same way, so a file count that disagrees with the entries actually present cannot leave a walk looping while it holds the directory's i_rwsem. In simplefs_try_remove_entry(), zero the freed slot's nr_blk and drop the now redundant blk_nr_files guard.
RoyWFHuang
force-pushed
the
bug/dir_walk_accounting
branch
from
August 12, 2026 12:57
19654ba to
add7479
Compare
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.
__file_lookup()andsimplefs_remove_from_dir()both walk a directory's extents block by block, but bound the walk differently:__file_lookup()subtracts a block'snr_filesbefore scanning the block.simplefs_remove_from_dir()bounds its inner loop by the extent length (ee_len) instead of by the number of files left to find.Neither skips blocks whose
nr_filesis 0, so an empty block is still walked entry by entry.nr_bi_files, and decrement it only after a block has been scanned.nr_filesis 0.simplefs_try_remove_entry(), zero the freed slot'snr_blkafter merging it into the preceding entry, and drop theblk_nr_filesguard that the caller's count-based loop makes redundant.Summary by cubic
Unifies directory block enumeration in
__file_lookup()andsimplefs_remove_from_dir()with consistent file-count and extent-length bounds, and skips empty blocks. Bounds outer loops bySIMPLEFS_MAX_EXTENTSto prevent infinite walks underi_rwsemand reduce unnecessary reads.nr_files == 0.SIMPLEFS_MAX_EXTENTSto avoid infinite walks when counts disagree with on-disk entries.simplefs_try_remove_entry(), zero the freed entry’snr_blkafter merging and remove the redundantblk_nr_filesguard.Written for commit add7479. Summary will update on new commits.