Repository navigation
fix: serialize same-node inode updates with a per-inode mutex - #18
Merged
Merged
Conversation
Goroutines on one node share cluster locks, so nothing stopped two of them from rewriting the same inode at once: - Two first writes into one fallocated block both zero-filled it, and the second wiped the first one's data. - A write could store its stale copy of the inode over a truncate that committed meanwhile, so the file mapped blocks the truncate freed. Write, Setattr and Allocate now take a striped in-process mutex around each attempt, and Setxattr (snapshot, clone) holds it for the whole call. It comes before any cluster lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattmattox
added a commit
that referenced
this pull request
Oct 24, 2026
…ims are confirmed (#22) Taking a lock is still a read then a write, so two nodes that claim a free inode lock at the same moment can both hold it. The test does that for 20 files per run and loses one node's write in about 1 file in 150: 4 of 30 runs failed on main and 2 of 30 on #13 before #18 and #20 landed, so #18 is not the cause. CI runs integration with -short; full runs still include it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Goroutines on one node share cluster locks, so two of them could rewrite one inode at the same time:
Fix:
Write,Setattr,AllocateandSetxattrtake an in-process mutex per inode (256 stripes) before any cluster lock. I sent the lock order to the #13 session.Reach: on one FUSE mount, the kernel already serializes
write,ftruncateandfallocateper file. The new mount test passes on main too, so it guards the behavior rather than reproducing the bug. Plain syscalls never hit these races. In-process callers can, and so might kernel paths that skip that lock, such as mmap writeback (not verified).Tests: the two unit tests fail 10/10 on main and pass 10/10 with
-racehere. Together they add about 10s to the unit tests.Cost: writes to the same file from one node no longer overlap.
🤖 Generated with Claude Code