fix(chunkstore): refuse oversized inherited fork geometry before claiming

This commit is contained in:
pingqiu committed 2026-11-18 21:36:07 -08:00
1 parent 1afc5ac00b
commit 5892e35217
3 files changed
+7 -4

No files matched your search

@@ -1356,6 +1356,9 @@ func (c *Catalog) claimForkParent(ctx context.Context, req ForkRequest) (Snapsho
if ref.info.State == SnapDeleting {
return SnapshotInfo{}, catErr(CodeSnapshotDeleting, false, nil, "snapshot %s/%s is being deleted", req.Source, req.Snapshot)
}
if ref.info.geo.BlockSize != 0 && ref.info.geo.NumBlocks > geometry.MaxVolumeBytes/uint64(ref.info.geo.BlockSize) {
return SnapshotInfo{}, catErr(CodeGeometryMismatch, false, nil, "fork size exceeds maximum %d bytes (16 TiB - 4 KiB; uint32 LBA)", geometry.MaxVolumeBytes)
}
claims := decodeClaims(ref.entry)
for _, cl := range claims {
if cl == token {
@@ -183,7 +183,7 @@ stateDiagram-v2
## 6. Snapshots, forks, retention, GC, volume delete
**Create capacity.** New volumes larger than 16 TiB - 4 KiB (17,592,186,040,320 bytes) are refused before provisioning, WAL allocation or durable VOLUME creation. CSI, lifecycle intent, Catalog and local WAL create share the same bound. A fork inherits the existing source geometry. Existing store-open formats are unchanged. This is static admission, not a new lifecycle state.
**Create capacity.** New volumes larger than 16 TiB - 4 KiB (17,592,186,040,320 bytes) are refused before provisioning, WAL allocation or durable VOLUME creation. CSI, lifecycle intent, Catalog and local WAL create share the same bound. A fork inherits its source geometry only within the same capacity bound; refusal leaves no parent claim. Existing store-open formats are unchanged. This is static admission, not a new lifecycle state.
- **Snapshot** (`Catalog.CreateSnapshot`): claim the name with an exclusive name record `{request, attempt}` (a retry gets its own attempt back); check the volume is not being deleted; write an intent with a deadline; re-check the deadline; exclusively create `snaps/<name>/<attempt>` holding a copy of the HEAD root. An unknown outcome keeps the intent; the caller retries with the same request id.
@@ -206,7 +206,7 @@ HEAD states:
```mermaid
stateDiagram-v2
[*] --> active: create within capacity bound (gen 1, epoch 0) or inherited fork HEAD
[*] --> active: create within capacity bound (gen 1, epoch 0) or inherited fork HEAD within capacity bound
active --> active: holder's cut CAS (gen+1)
active --> detached: Detach final cut
detached --> active: takeover CAS (higher epoch, new holder)
+2 -2
View File
@@ -247,7 +247,7 @@ HEAD states, snapshots, forks, intents, key bindings, GC and volume delete in th
| — | name held | exclusive name record `{request, attempt}`; a retry with the same request id gets its own attempt back | `core/frontend/chunkstore/catalog.go` `CreateSnapshot`, `claimName` | `INV-SNAP-EXPLICIT-DELETE-001` |
| name held | published | the volume is not being deleted; an intent with a deadline is written and the deadline is re-checked; exclusive create of the attempt path | `core/frontend/chunkstore/catalog.go` `CreateSnapshot` | `INV-SNAP-EXPLICIT-DELETE-001` |
| published | deleting | `DeleteSnapshot` or retention for this attempt, never while a fork claim is live | `core/frontend/chunkstore/catalog.go` `DeleteSnapshot`; `core/frontend/chunkstore/retention.go` `markDeleting` | `INV-SNAP-EXPLICIT-DELETE-001` |
| published | fork | claim the parent snapshot, check the source is not being deleted, write the target `VOLUME`, then its HEAD; no chunk is copied | `core/frontend/chunkstore/catalog.go` `Fork`, `claimForkParent` | `INV-GC-REACHABLE-001` |
| published | fork | require inherited geometry within the create capacity bound; require inherited geometry within the create capacity bound; claim the parent snapshot, check the source is not being deleted, write the target `VOLUME`, then its HEAD; no chunk is copied | `core/frontend/chunkstore/catalog.go` `Fork`, `claimForkParent` | `INV-GC-REACHABLE-001` |
**Intents and key bindings.**
@@ -473,7 +473,7 @@ Notes:
| ID | Invariant | Transition | Enforced in | Regression tests | Model | Status |
|---|---|---|---|---|---|---|
| `INV-VOLUME-CREATE-SIZE-001` | Creation refuses capacity above 16 TiB - 4 KiB before provisioning, allocating a WAL, or persisting a volume record. Geometry checks cannot overflow. | M6 initial create (static parameter admission) | `core/geometry/volume_size.go`; lifecycle `CreateVolume`, CSI `volumeSpecFromCreateRequest`, catalog `EnsureVolume`, storage `CreateWALStoreWithOptions` | `TestCreateVolumeRejectsBeyondUint32LBACap`, `TestCSICreateVolumeCapacityCapBeforeProvision`, `TestEnsureVolumeRejectsBeyondUint32LBACap`, `TestCreateWALStoreRefusesOversizeBeforeFilesystem` | Static geometry bound; no protocol state or transition added | ACTIVE |
| `INV-VOLUME-CREATE-SIZE-001` | Creation refuses capacity above 16 TiB - 4 KiB before provisioning, allocating a WAL, or persisting a volume record. Geometry checks cannot overflow. | M6 initial create (static parameter admission) | `core/geometry/volume_size.go`; lifecycle `CreateVolume`, CSI `volumeSpecFromCreateRequest`, catalog `EnsureVolume`, `claimForkParent`, storage `CreateWALStoreWithOptions` | `TestCreateVolumeRejectsBeyondUint32LBACap`, `TestCSICreateVolumeCapacityCapBeforeProvision`, `TestEnsureVolumeRejectsBeyondUint32LBACap`, `TestCreateWALStoreRefusesOversizeBeforeFilesystem`, `TestForkRejectsLegacyOversizedGeometry` | Static geometry bound; no protocol state or transition added | ACTIVE |
## Part C. Change rules