Skip to content

feat(journal): record block reserves so replay and fsck free a crashed node's unused ones - #139

Merged
mattmattox merged 2 commits into
mainfrom
feat/block-reserve-journal
Nov 14, 2026
Merged

mattmattox merged 2 commits into
mainfrom
feat/block-reserve-journal

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

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 -force while a journal is dirty) frees a crashed node's unused reserve only after writing its intent completions into that node's journal. TestFsckRepairFreesCrashedNodesReserveOnce fails without that step.

🤖 Generated with Claude Code

mattmattox and others added 2 commits November 13, 2026 23:21
…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>
@mattmattox
mattmattox merged commit 634e5a1 into main Nov 14, 2026
17 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