Skip to content

fix(fsck): report sharing past the refcount table - #44

Merged
mattmattox merged 3 commits into
mainfrom
claude/fsck-refcount-coverage
Oct 24, 2026
Merged

mattmattox merged 3 commits into
mainfrom
claude/fsck-refcount-coverage

Conversation

@mattmattox

@mattmattox mattmattox commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #39, from its review. On volumes over about 128 GiB, fsck could not see sharing that the refcount table has no counts for. Repair also made it worse.

Against main's fsck, the new test shows three gaps on a 200 GiB image:

  • Two inodes share block 130821 with counts, and the check exits 0. A delete would free that block while the other inode still maps it.
  • There is no coverage warning.
  • -repair marks old uncounted sharing of block 130825 counted, so its first release frees it.

Now fsck warns about the coverage gap and reports Critical for each such block, capped at 10 like phase 8. Repair leaves old sharing past the table uncounted, which means never freed. Those inodes are reported as Error (exit 4): writes to one file change the others, because copy-on-write reads a count of 0 past the table. The fix is to copy the file and delete the original.

This doesn't depend on #39's code, and merges cleanly with it in either order.

🤖 Generated with Claude Code

mattmattox and others added 3 commits October 24, 2026 18:22
The 1 MB refcount table has entries for blocks 0-130815, but phase 5
only checked entries inside it. On larger volumes a block past the
table that several inodes share with counts reads as having one owner,
so deleting one of them frees it while the others still map it. fsck
missed this, and repair marked older uncounted sharing of such blocks
counted, which turns "never freed" into "freed on the first release".

fsck now warns when the volume has more blocks than the table covers,
reports such multiply mapped blocks as Critical, and reports inodes
with older sharing past the table without marking them counted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The write path decides copy-on-write from the refcount, which reads 0
past the table, so a write to one file of such older sharing changes
the others. Repair cannot count those blocks, so report the inode as an
error and tell the user to copy the file apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit e784b2d into main Oct 24, 2026
8 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