Skip to content

fix(dir): recount the parent's links when a mkdir or rmdir write fails - #186

Merged
mattmattox merged 2 commits into
mainfrom
fix/dir-eio-links
Nov 17, 2026
Merged

mattmattox merged 2 commits into
mainfrom
fix/dir-eio-links

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Fixes the main CI flake in TestOneFailedWriteKeepsAcknowledgedResults (Unit Tests group 2, on 125d4ae): "inode 2: directory has 3 links, want 2".

mkdir and rmdir write the parent's inode, carrying the link-count change, before the entry's chunk. If the chunk write fails with EIO, the count stays changed without the entry. The failed operation closes its intent, so replay never fixes it. This wasn't new in #181: before #181 the separate parent update could fail the same way, and #181's warning made it visible.

Now, when an add or remove fails after an inode write that carried a parent update, it recounts the parent from its entries under the locks it already holds.

The new tests fail each write of one mkdir or rmdir in turn, with no crash, and check the root's link count. They fail on main and pass here.

Verified on .68: lint, unit, -race on goclusterfs, -short integration (150 pass, 0 fail), parity, and GOCLUSTERFS_EIO_SWEEP=metadata on the EIO sweep and the new tests.

Not covered here: rename completes its intent even when dir.Rename fails after its journal commit. So an EIO partway through a rename leaves a partial rename that replay never finishes. That needs its own fix.

🤖 Generated with Claude Code

mattmattox and others added 2 commits November 16, 2026 20:11
mkdir and rmdir write the parent's inode, carrying the link count change,
before the entry's chunk. When the chunk write failed with EIO, the count
stayed changed without the entry, and the failed operation closed its intent,
so replay never fixed it. Main CI's EIO sweep hit this in group 2.

Now a failed add or remove whose inode write carried a parent update recounts
the parent from its entries, under the locks it already holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit fce1a23 into main Nov 17, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant