Repository navigation
fix(fs): keep a file unlinked while open until every node closes it - #161
Merged
Merged
Conversation
Unlinking a file that a descriptor still had open freed its inode at once, so the descriptor read and wrote whatever file took the inode next, on any node. A file that loses its last link now stays as an orphan: LinkCount 0 and one Holders bit per registry slot that may still have it open. Each node clears its bit at its last close, and whoever clears the last bit frees the file. The unlinking node lists the orphan in its registry slot so peers find it, and an Orphans broadcast tells them at once. A full list waits while peers free entries, then fails the unlink with EBUSY. The journal logs LinkDrop instead of an nlink update, so replay redoes a lost drop. A peer clears a dead node's bits after replaying its journal, and a clean unmount clears the node's own. File.Open and Create return a file handle, without which go-fuse never calls Release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A node that still has an unlinked file open may open it again through /proc/self/fd, as local filesystems allow. Its holder bit keeps the inode from being freed or reused meanwhile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a peer mounted, a removed file is freed once the peer lets go of it, on the Orphans broadcast or at its next failure scan, so inode reuse and freed blocks show up a moment after the remove. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A node alone that unlinked a file it had open did not list the orphan, so after a crash nothing found it and it leaked until fsck -repair. Such orphans are now listed, and the next mount of the slot frees them. A full orphan list now keeps waiting while a peer has stopped heartbeating or awaits replay, as lock waits do, and gives EBUSY only when live peers stop freeing for 20 s. Replay now frees the SFB slot of an orphan it frees. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The unlinking node lists a file before its last link goes. A peer that looked in that window remembered the entry as done, and the node's own prune dropped it as stale, so after the drop nobody freed the file until its holder unmounted. Both now leave a still-linked entry alone; only the node's own mount and unmount drop such entries, which a crash left. The many-removes test now checks that peers free every file while still mounted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 16, 2026
mattmattox
added a commit
that referenced
this pull request
Nov 16, 2026
Every inode rewrite wrote reserved bytes 212-251 as zero. A future field there would be wiped whenever this build rewrote the inode, which is how older builds lost the birth generation at 196-203. The inode now keeps those bytes as read and writes them back, as #158 did for snapshot descriptors. Freeing or claiming a slot still starts from a zeroed inode. main is merged in, including #161. Holders keeps bytes 204-211, so Reserved is now 40 bytes (212-251). The merge commit holds that change plus the new test; the first commit's message still says 204-251. Tests: - FuzzDeserializeInode now checks the re-encoded bytes. Its seed sets both Holders and the reserved bytes. - New TestRewriteChangesHoldersAndKeepsReservedBytes: through the Table, a Holders change reaches disk and the reserved bytes survive. It fails if a rewrite puts back the Holders read from disk. - Fuzzed 3 min on .66 with no failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This was referenced Nov 16, 2026
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.
A descriptor opened before an unlink kept writing into whatever file took the inode next, on any node. The history checker (#156) found it;
TestFileUnlinkedWhileOpenKeepsItsDataproves it.Trade-offs:
/proc/self/fd.Verified on .68 before rebasing onto #155/#160: lint, unit,
-race,-shortintegration (the two timing tests it broke are fixed in the last commit), parity, and the unlink and recovery tests.🤖 Generated with Claude Code