Repository navigation
feat(journal): record block reserves so replay and fsck free a crashed node's unused ones - #139
Merged
Merged
Conversation
…d node's unused ones Groundwork for per-node block reserves. A BlockReserve record lists blocks a node marked allocated to hand out later; a BlockUse record marks reserved blocks an inode may map before their extents are logged. Replay finds, before it moves the head, the blocks pending reserve records hold that no later record used, and frees them after the last transaction and before the reset, so a failed replay leaks them rather than freeing them twice. fsck reports them as reserved instead of leaked, and repair marks the reserve done in the crashed node's journal before it frees them. Nothing writes these records yet. 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.
PR 3a of the per-node block reserve work: the crash safety, before anything writes reserves. PR 3b adds the runtime reserve on top.
A write can map a new block in the inode on disk before the transaction that logs it commits, because it persists the inode mid-write. So "replay frees reserved blocks no ExtentAdd used" is only safe if every reserve block is logged as used before any inode write can map it. That's what the BlockUse record is for; 3b writes it before such a persist.
Replay skips completed intents, but completed writes are exactly the ones that used reserved blocks. So the unused set comes from a separate pre-scan that reads completed transactions too. The pre-scan runs before replay moves the head, and the blocks are freed after the last transaction. A replay that dies partway therefore leaks them for fsck rather than freeing them twice.
fsck -repair(which needs-forcewhile a journal is dirty) frees a crashed node's unused reserve only after writing its intent completions into that node's journal.TestFsckRepairFreesCrashedNodesReserveOncefails without that step.🤖 Generated with Claude Code