Repository navigation
fix(fs-core): release removed inodes in rm and rmdir - #1302
Open
pawelzwronek wants to merge 1 commit into
Open
pawelzwronek wants to merge 1 commit into
pawelzwronek wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
rm()andrmdir()remove directory entries but leave the removed nodes inSuperblock.inodes, retaining their file buffers for the lifetime of the volume. Repeatedly creating and removing the same files therefore accumulates unreachable file data.Release the removed subtree's inodes after detaching its directory entry. Skip
.and.., decrement each removed file's link count, and retain nodes with hard links outside the subtree. Open files keep their existing Node and buffer through the descriptor table, so reads remain valid after removal.Add 10 deterministic regression cases covering individual files, recursive
rm/rmdir, empty directories, hard links inside and outside the subtree, open descriptors, symlinks inside a subtree, and inode-number reuse. All 10 fail before the fix and pass afterward. The tests inspect inode ownership rather than relying on GC timing or RSS.Validation on Windows x64, Node v24.13.1, Yarn 4.12.0:
yarn test: 101 suites passed; 1627 tests passed, 18 skipped; 14 snapshots passed.yarn typecheckpasses.yarn prettier:checkpasses.no-duplicate-importsviolation atSuperblock.ts:8; the same violation occurs on the original HEAD file. The new test file has no TSLint violations. TSLint is not part of the current checks workflow.--expose-gcbenchmark against the built checkout creates 256 files of 2 MiB per round. After three rounds for each of rm, recursive rm, and unlink,arrayBuffersreturns to 2.04 MiB, with only the root inode and zero descriptors remaining. The benchmark retains a 2 MiB source buffer deliberately.The change keeps existing path resolution, permission checks and volume-level deletion events. It does not attempt to fix separate symlink-resolution behavior in
rm.GPT-6.1 Sol ran all the tests and created the fix. I only spotted a memory leak after using rmSync() :P