Repository navigation
fix(snapshot): copy shared blocks under the exclusive inode lock - #46
Merged
Merged
Conversation
A write that copies a shared block read the old block before it took the inode lock. An in-place write on another node could still be landing in that block, since the block became shared only after it checked, and the copy's commit check compared MetaGeneration, which in-place writes do not change. The acknowledged write was lost. The copy is now mapped before the lock, as allocating it may take bitmap and tree blocks, and its data is read and written under the exclusive inode lock, which waits for in-place writes holding the shared one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A write that copied a shared block and then failed before any inode write left the copy allocated with nothing pointing at it. Free it on that path. A failed inode write may still have reached the disk, so copies it carried stay allocated, as before. CopyOnWrite is only used by the extent tests now, so it moves to a test file. 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.
Fixes the three-node lost write found in #42's review, which predates #42. Node A writes a block in place after its re-check, node B's snapshot raises the block's count, and node C copies the block before A's data lands. C's commit check compares MetaGeneration, which in-place writes don't change, so A's acknowledged write was lost.
The new test fails on #42's code with only its hooks added ("data mismatch at offset 0") and passes 10 of 10 with -race here.
I/O per write, measured on .68:
This PR leaves in-place cost unchanged, and copy-on-write writes no longer re-check the refcount. The 1MB copy now happens under the exclusive inode lock, so it blocks the file's other writers while it runs.
Tested on .68: lint, unit -race, integration -short (90 passed, 17 skipped).
🤖 Generated with Claude Code