Skip to content

fix(snapshot): keep each snapshot with the file it was taken of - #140

Merged
mattmattox merged 3 commits into
mainfrom
fix/snapshot-owner-generation
Nov 14, 2026
Merged

mattmattox merged 3 commits into
mainfrom
fix/snapshot-owner-generation

Conversation

@mattmattox

@mattmattox mattmattox commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Snapshots matched their file by inode number alone. After a file was deleted, a new file in the same inode slot listed its snapshots, could delete them, and could clone them, reading the deleted file's data. TestSnapshotStaysWithItsFile reproduces this: before the fix, the new file listed s:active and the clone and delete both succeeded.

Design. The inode generations from #7 change over a file's life, so they can't identify a file on their own.

  • An inode now records a birth generation when it takes a slot, in reserved bytes 196–203. It is the slot's MetaGeneration plus one, higher than any generation the slot's earlier files reached.
  • An inode from an older build gets its birth generation lazily, on its first snapshot.
  • Each descriptor records its file's birth generation, 48 bits, in the reserved bytes 26–27 and 32–35, behind a new flag.
  • Listing, clone and delete through a file, and the API's per-file listing, match both the inode number and the birth generation.

Orphans. A snapshot is an orphan when its file is gone, or when an older build wrote it without a birth generation.

  • GET /api/v1/snapshots marks orphans with orphan: true.
  • DELETE /api/v1/snapshots/<name> without path deletes an orphan, and only an orphan.
  • fsck warns about each orphan and gives the reason.

Upgrade impact. Existing snapshots become orphans after upgrade: they leave getfattr listings and can no longer be cloned. The CHANGELOG says so. The dashboard doesn't show orphans yet.

Tested on .66.

  • go test -race ./internal/...: all packages pass after the test fix in db7eacc. goclusterfs took 351 s.
  • Full 2-node VM suite: 62/64 at 64c07a5. The 2 failures were the VM fsck check treating orphan warnings as damage, now fixed. Those tests and Snapshot Preserves Data then passed.

🤖 Generated with Claude Code

mattmattox and others added 3 commits November 13, 2026 22:38
Snapshots matched files by inode number alone, so a new file that reused
a deleted file's inode slot listed its snapshots, could delete them, and
could clone them, reading the deleted file's data.

Inodes now record a birth generation when they take a slot, above every
generation the slot's earlier files reached, and each snapshot records
its file's. Listing, clone and delete through a file, and the API's file
listing, match number and birth. Snapshots of deleted files, and those
older versions wrote without a birth, are orphans: the API's full listing
marks them, a delete without a path removes them, and fsck warns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nings in VM fsck checks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit cfb5e97 into main Nov 14, 2026
17 checks passed
mattmattox added a commit that referenced this pull request Nov 14, 2026
Since #140, bytes 26-27 and 32-35 hold the birth generation only with
FlagHasTargetBirth. Without the flag, decoding ignores them and
re-encoding writes zeros, so the checksum changes while every field
stays the same. FuzzDecodeDescriptor compared the stored checksum too
and failed on such descriptors; it now compares the fields. The input
that found it is kept.

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