Skip to content

fix: check ignored errors in lock, inode and extent; enforce errcheck there - #95

Merged
mattmattox merged 2 commits into
mainfrom
claude/errcheck-lock-inode-extent
Nov 13, 2026
Merged

mattmattox merged 2 commits into
mainfrom
claude/errcheck-lock-inode-extent

Conversation

@mattmattox

@mattmattox mattmattox commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes all 83 errcheck findings in internal/{lock,inode,extent} and adds those packages to the path-except rule. journal, storage and refcount were already enforced by #31. 438 findings remain elsewhere.

Ignored errors that could hide corruption:

  • Inode table lock release (inode.Table updates, inode and sector locks): ErrNotLockOwner from Release means a double release or a lock bookkeeping bug. Since fix(lock): take over a lock only after its holder is released #90 that is the only cause; another node never takes over a live node's lock. The extra release may have dropped another holder's lock early, so two writers could have updated the inode table at once. This used to show only as a [DEBUG] line inside lock. It is now an [ERROR].
  • Unmapped blocks after a failed extent allocate or MapCopy: if freeing them failed, they stayed allocated with no owner. That's a leak, not corruption. The returned error now names the blocks.

lock.WithInodeLock now returns the release error; nothing in production calls it.

Tests: setup steps are now checked. Lock tests use a release helper that reports with Errorf, so goroutines and defers can call it. Lint and unit tests with -race pass on .68.

🤖 Generated with Claude Code

mattmattox and others added 2 commits November 13, 2026 14:01
… there

- inode table: a failed lock release after an inode or sector update
  was dropped. If another node had taken the lock over, both nodes may
  have written the same inode table sector. Now logged as an error with
  that reason; other release failures log a warning.
- extent: when allocate or MapCopy fail, the blocks they took are freed
  again. A failed free left them allocated with no owner and no trace;
  the returned error now names each one.
- lock.WithInodeLock now returns the release error.
- Tests check setup steps and lock releases; lock tests use a release
  helper that reports failures with Errorf, so goroutines can use it.

errcheck is now enforced in lock, inode and extent too; 438 findings
remain elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #90 no node takes over a live node's lock. Release returns
ErrNotLockOwner only when this node's own bookkeeping lacks the lock, a
double release that may have dropped another holder's lock early.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit ebef62b into main Nov 13, 2026
13 checks passed
mattmattox added a commit that referenced this pull request Nov 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mattmattox added a commit that referenced this pull request Nov 13, 2026
…eplay mkdir and claimed creates whole (#94)

* fix(fs): remove a name only while it names the inode the lookup found

Unlink and rmdir looked up the child, then removed the name and freed the
child by that lookup. If another node removed the name and made a new one in
between, they removed the new name and freed with stale extents. The removal
now checks the child under the directory lock: a name that points to another
inode returns ENOENT, and a changed child is looked up again. The free uses
what the inode maps when it is freed. Name errors map to EEXIST and ENOENT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(journal): replay a mkdir whole, and finish a create whose claim landed

A replayed mkdir now gets "." and ".." and raises the parent's link count,
under the parent's inode lock. A create that crashed after claiming its inode
used to leave it unnamed: replay now names it when the logging node wrote it
last, and no more often than a create does before naming it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test: unlink racing a peer's recreate, replayed mkdir and claims, and name errors

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(fs): unlink racing a peer that puts a directory in the same slot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dir): report a directory whose inode is already free as removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(journal): build the root with newRootDir now that replay sets up directories

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(fs): unlink frees blocks an open handle wrote after the name was removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(fs): let unlink proceed when another node only wrote the file

Every write raises a file's generation, so unlink of a file another node kept
writing ran out of retries with EAGAIN. A file now only has to keep its type
and link count; a directory still has to be unchanged, since an entry added
to it changes its generation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(inode): release the Update lock through t.unlock, as #95 does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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