Repository navigation
feat(fsck): check the directory tree - #181
Merged
Merged
Conversation
Phase 6 now reports a directory with more than one name, a ".." that does not name the directory that names it, a directory link count other than 2 plus its subdirectories, and a ".." chain that loops instead of reaching the root. It checks only when every directory was readable, and repair leaves directories alone. One test built a subdirectory without counting it in the root's links, as mkdir does; it now counts it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cuts mkdir and rmdir changed the parent's entry and its link count under separate locks, and replay did not fix the count, so a power cut between them left the count off by one. fsck's new tree check reported it. The count now changes in the same parent inode write as the entry. That write lands before the chunk, so replay of a mkdir or rmdir sets the parent's count from its subdirectories instead of adding or subtracting one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
mattmattox
added a commit
that referenced
this pull request
Nov 17, 2026
…s do after #181 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattmattox
added a commit
that referenced
this pull request
Nov 17, 2026
…172) * feat(fs): symlinks, with targets inline in the inode or in one block symlink, readlink, lstat, lchown and lutimes work through FUSE; the kernel follows links itself. A target of up to 92 bytes is kept in the inode bytes the inline extents and tree fields use, under a new FlagInlineTarget; the inode decoder leaves the extents zero for such an inode, so nothing that walks extents reads target bytes as blocks. A longer target, up to 4095 bytes, goes in one zeroed data block mapped like a one-block file. -format sets the new RequiredSymlinks superblock flag, so older builds and fsck refuse such volumes; on older volumes symlink returns EOPNOTSUPP. Creating a link is one transaction: InodeCreate, a new SymlinkTarget entry and DirAddEntry (plus BlockUse for a reserved block). It claims the inode before naming it, and replay applies the target only to an inode that replay itself created. fsck parses inline targets, checks symlink link counts, lengths, layout, padding and targets, and checks that DT_LNK entries and symlink inodes match. It reports bad symlinks without repairing them; an unnamed one goes through the existing unnamed-inode repair. Snapshots and clones of a symlink are refused: a Link node takes no xattrs, as the kernel refuses user xattrs on symlinks anyway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: keep the symlink comments to one line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(fs): free a symlink's inode at its last unlink, since no node can hold one open Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: gofmt the symlink tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(fs): never let a stale symlink node reach the next symlink in its slot A symlink node did not check the inode's birth generation, so once its link was unlinked and another symlink took the slot, readlink and lchown through the old node reached the new link. The symlink unlink fast path made that reuse immediate. Link nodes now record the birth generation, pass it to go-fuse as the generation, and return ESTALE when the slot holds another link, as #169 does for files. A symlink create that fails after its commit now ends the intent durably before it frees the target block, so replay cannot map a block this node already freed; if that fails, the block stays allocated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(fs): name a symlink and update its parent in one write, as creates do after #181 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
mattmattox
added a commit
that referenced
this pull request
Nov 17, 2026
* feat(fs): symlinks, with targets inline in the inode or in one block symlink, readlink, lstat, lchown and lutimes work through FUSE; the kernel follows links itself. A target of up to 92 bytes is kept in the inode bytes the inline extents and tree fields use, under a new FlagInlineTarget; the inode decoder leaves the extents zero for such an inode, so nothing that walks extents reads target bytes as blocks. A longer target, up to 4095 bytes, goes in one zeroed data block mapped like a one-block file. -format sets the new RequiredSymlinks superblock flag, so older builds and fsck refuse such volumes; on older volumes symlink returns EOPNOTSUPP. Creating a link is one transaction: InodeCreate, a new SymlinkTarget entry and DirAddEntry (plus BlockUse for a reserved block). It claims the inode before naming it, and replay applies the target only to an inode that replay itself created. fsck parses inline targets, checks symlink link counts, lengths, layout, padding and targets, and checks that DT_LNK entries and symlink inodes match. It reports bad symlinks without repairing them; an unnamed one goes through the existing unnamed-inode repair. Snapshots and clones of a symlink are refused: a Link node takes no xattrs, as the kernel refuses user xattrs on symlinks anyway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: keep the symlink comments to one line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(fs): free a symlink's inode at its last unlink, since no node can hold one open Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: symlinks across nodes and in the soak driver Go integration, Docker and VM tests make symlinks with an inline and a block target on one node, read them with readlink and lstat and read a file through one on another node, and remove one there. The soak driver gains a symlink op (a lane file, a missing name, or a target too long for the inode) and unlinks links; directory listings now show each link with its target, so every check compares targets on all nodes, including after faults and replay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: gofmt the symlink tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(fs): never let a stale symlink node reach the next symlink in its slot A symlink node did not check the inode's birth generation, so once its link was unlinked and another symlink took the slot, readlink and lchown through the old node reached the new link. The symlink unlink fast path made that reuse immediate. Link nodes now record the birth generation, pass it to go-fuse as the generation, and return ESTALE when the slot holds another link, as #169 does for files. A symlink create that fails after its commit now ends the intent durably before it frees the target block, so replay cannot map a block this node already freed; if that fails, the block stays allocated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(fs): name a symlink and update its parent in one write, as creates do after #181 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: symlinks lack only hard links now; keep soak symlinks out of a full lane Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: phase 6 checks every entry type, not only symlinks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 17, 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.
Rename PR 2 of 3: fsck checks the directory tree that rename can now change. Phase 6 reports:
..that does not name the directory that names it;..chain that loops instead of reaching the root (reported once per loop, with its members).The checks run only when every directory was readable, so a damaged directory can't cause false reports. Repair leaves directories alone, as for other directory problems. Each check has a test that corrupts a mkdir-built tree one way; the clean tree passes. File link counts (one per name) belong to the hard-link work.
One existing test added a subdirectory without counting it in the root's links, as mkdir does; it now counts it.
Link count fix (second commit). The new warning exposed a real bug: a power cut during mkdir or rmdir left the parent's link count off by one. The entry and the count were written under separate locks, and replay never fixed the count. Now the count changes in the same parent inode write as the entry. That write lands before the chunk, so replay sets the parent's count from its subdirectories instead of adding one.
TestPowerCutDuringMkdirandTestPowerCutDuringRmdircut power at every write.Verified on .68 at da23330: lint, unit,
-raceon goclusterfs,-shortintegration (150 pass, 0 fail), parity. VM on .66: the 6 power-failure tests and 6 crash-recovery tests pass.🤖 Generated with Claude Code