From aa2397562407fe66112e74c3566fec2e57171439 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 27 Nov 2026 17:58:23 -0800 Subject: [PATCH 1/4] fix: refuse a new volume above the maximum size at both create doors CreateVolume and the cluster-spec start check refuse a new volume above geometry.MaxNewVolumeBytes with ErrVolumeTooLarge, naming the size and the maximum, before any record or store exists. The check is at creation only: a volume that already exists keeps opening under the uint32-LBA limit. The value is a placeholder (MaxVolumeBytes) until it is set from the measured capacity limit. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/cmd/blockmaster/cluster_spec.go | 4 ++ .../blockmaster/cluster_spec_max_size_test.go | 48 +++++++++++++++++ seaweed-block/core/geometry/volume_size.go | 25 ++++++++- .../core/geometry/volume_size_new_test.go | 18 +++++++ .../core/host/master/max_volume_size_test.go | 52 +++++++++++++++++++ seaweed-block/core/lifecycle/store.go | 2 +- .../core/lifecycle/volume_size_limit_test.go | 7 ++- seaweed-block/docs/design/invariants.md | 1 + 8 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go create mode 100644 seaweed-block/core/geometry/volume_size_new_test.go create mode 100644 seaweed-block/core/host/master/max_volume_size_test.go diff --git a/seaweed-block/cmd/blockmaster/cluster_spec.go b/seaweed-block/cmd/blockmaster/cluster_spec.go index acb356548a..5e6c17b2d9 100644 --- a/seaweed-block/cmd/blockmaster/cluster_spec.go +++ b/seaweed-block/cmd/blockmaster/cluster_spec.go @@ -4,6 +4,7 @@ import ( "fmt" "os" + "github.com/seaweedfs/seaweed-block/core/geometry" "github.com/seaweedfs/seaweed-block/core/lifecycle" "gopkg.in/yaml.v3" ) @@ -102,6 +103,9 @@ func clusterSpecToImports(spec clusterSpecFile) (clusterSpecImport, error) { } // Placement-only legacy specifications cannot supply a capacity. They // retain the explicit CreateVolume prerequisite rather than inventing one. + if err := geometry.ValidateNewVolumeSize(vol.SizeBytes); err != nil { + return clusterSpecImport{}, fmt.Errorf("cluster spec: volume %q: %w", vol.ID, err) + } if vol.SizeBytes > 0 { out.Volumes = append(out.Volumes, lifecycle.VolumeSpec{VolumeID: vol.ID, SizeBytes: vol.SizeBytes, ReplicationFactor: vol.ReplicationFactor}) } diff --git a/seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go b/seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go new file mode 100644 index 0000000000..b3ae9588df --- /dev/null +++ b/seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go @@ -0,0 +1,48 @@ +package main + +import ( + "errors" + "os" + "path/filepath" + "strconv" + "strings" + "testing" + + "github.com/seaweedfs/seaweed-block/core/geometry" +) + +// The cluster spec is read before blockmaster starts serving: a volume of +// exactly MaxNewVolumeBytes is imported, one chunk more refuses the start +// with an error naming the volume and the maximum. +func TestClusterSpecRefusesAVolumeAboveTheMaximum(t *testing.T) { + for _, c := range []struct { + name string + size uint64 + ok bool + }{ + {"at the maximum", geometry.MaxNewVolumeBytes, true}, + {"one chunk above", geometry.MaxNewVolumeBytes + 4<<20, false}, + } { + t.Run(c.name, func(t *testing.T) { + b, err := os.ReadFile(writeClusterSpecForTest(t)) + if err != nil { + t.Fatal(err) + } + path := filepath.Join(t.TempDir(), "spec.yaml") + raw := strings.Replace(string(b), " size_bytes: 1048576\n", " size_bytes: "+strconv.FormatUint(c.size, 10)+"\n", 1) + if err := os.WriteFile(path, []byte(raw), 0o600); err != nil { + t.Fatal(err) + } + imports, err := loadClusterSpec(path) + if c.ok { + if err != nil || len(imports.Volumes) != 1 || imports.Volumes[0].SizeBytes != c.size { + t.Fatalf("volume of %d bytes: %+v, %v", c.size, imports.Volumes, err) + } + return + } + if !errors.Is(err, geometry.ErrVolumeTooLarge) || !strings.Contains(err.Error(), `"v1"`) || !strings.Contains(err.Error(), strconv.FormatUint(geometry.MaxNewVolumeBytes, 10)) { + t.Fatalf("volume of %d bytes: got %v, want ErrVolumeTooLarge naming v1 and the maximum", c.size, err) + } + }) + } +} diff --git a/seaweed-block/core/geometry/volume_size.go b/seaweed-block/core/geometry/volume_size.go index a1e941e327..6263383459 100644 --- a/seaweed-block/core/geometry/volume_size.go +++ b/seaweed-block/core/geometry/volume_size.go @@ -1,13 +1,36 @@ // Package geometry defines shared volume capacity limits at creation boundaries. package geometry -import "fmt" +import ( + "errors" + "fmt" +) // MaxVolumeBytes is the uint32-LBA limit with the supported 4-KiB IO unit. // This byte cap assumes that IO unit: support for another block size must // enforce min(MaxVolumeBytes, (2^32-1)*blockSize) at creation as well. const MaxVolumeBytes uint64 = (16 << 40) - 4096 +// MaxNewVolumeBytes is the largest volume this release creates (CreateVolume +// and a cluster spec's volumes). It is checked only where a volume is +// created, so a volume that already exists keeps opening under +// MaxVolumeBytes. A restore target takes its source's size. +// Placeholder value: MaxVolumeBytes, until it is set from the measured +// capacity limit. +const MaxNewVolumeBytes uint64 = MaxVolumeBytes + +// ErrVolumeTooLarge refuses a new volume above MaxNewVolumeBytes. +var ErrVolumeTooLarge = errors.New("volume too large") + +// ValidateNewVolumeSize refuses a new volume above MaxNewVolumeBytes; the +// error names the maximum. +func ValidateNewVolumeSize(size uint64) error { + if size > MaxNewVolumeBytes { + return fmt.Errorf("%w: %d bytes exceeds the maximum of %d bytes", ErrVolumeTooLarge, size, MaxNewVolumeBytes) + } + return ValidateVolumeSize(size) +} + // ValidateVolumeSize rejects an unsupported capacity before any allocation or // durable create. Division also makes block geometry checks overflow-safe. func ValidateVolumeSize(size uint64) error { diff --git a/seaweed-block/core/geometry/volume_size_new_test.go b/seaweed-block/core/geometry/volume_size_new_test.go new file mode 100644 index 0000000000..8a247295ad --- /dev/null +++ b/seaweed-block/core/geometry/volume_size_new_test.go @@ -0,0 +1,18 @@ +package geometry + +import ( + "errors" + "testing" +) + +func TestValidateNewVolumeSizeAtAndAboveTheMaximum(t *testing.T) { + if MaxNewVolumeBytes > MaxVolumeBytes { + t.Fatalf("MaxNewVolumeBytes %d is above MaxVolumeBytes %d", MaxNewVolumeBytes, MaxVolumeBytes) + } + if err := ValidateNewVolumeSize(MaxNewVolumeBytes); err != nil { + t.Fatalf("at the maximum: %v", err) + } + if err := ValidateNewVolumeSize(MaxNewVolumeBytes + 4<<20); !errors.Is(err, ErrVolumeTooLarge) { + t.Fatalf("one chunk above: %v, want ErrVolumeTooLarge", err) + } +} diff --git a/seaweed-block/core/host/master/max_volume_size_test.go b/seaweed-block/core/host/master/max_volume_size_test.go new file mode 100644 index 0000000000..fbc6fdfa99 --- /dev/null +++ b/seaweed-block/core/host/master/max_volume_size_test.go @@ -0,0 +1,52 @@ +package master + +import ( + "context" + "strconv" + "strings" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/authority" + "github.com/seaweedfs/seaweed-block/core/geometry" + "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" +) + +// CreateVolume, through the master's gRPC service as production serves it, +// creates a volume of exactly MaxNewVolumeBytes and refuses one chunk more +// with InvalidArgument naming the maximum; the refused id gets no record. +func TestCreateVolumeRefusesAVolumeAboveTheMaximum(t *testing.T) { + m, err := New(Config{Listen: "127.0.0.1:0", AuthorityStoreDir: t.TempDir(), LifecycleStoreDir: t.TempDir(), WorkspaceRPC: true, LayoutCreateVolume: testLayoutCreateVolume, + WorkspaceHeadReader: func(context.Context, string) (authority.WorkspaceHead, error) { return authority.WorkspaceHead{}, nil }}) + if err != nil { + t.Fatal(err) + } + m.Start() + defer closeTestMaster(t, m) + conn, err := grpc.NewClient(m.Addr(), grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + t.Fatal(err) + } + defer conn.Close() + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + lc := control.NewLifecycleServiceClient(conn) + + if _, err := lc.CreateVolume(ctx, &control.CreateVolumeRequest{VolumeId: "at-max", SizeBytes: geometry.MaxNewVolumeBytes, ReplicationFactor: 1}); err != nil { + t.Fatalf("a volume of exactly the maximum (%d bytes) is refused: %v", geometry.MaxNewVolumeBytes, err) + } + _, err = lc.CreateVolume(ctx, &control.CreateVolumeRequest{VolumeId: "over-max", SizeBytes: geometry.MaxNewVolumeBytes + 4<<20, ReplicationFactor: 1}) + if status.Code(err) != codes.InvalidArgument { + t.Fatalf("one chunk above the maximum: got %v, want InvalidArgument", err) + } + if msg := status.Convert(err).Message(); !strings.Contains(msg, geometry.ErrVolumeTooLarge.Error()) || !strings.Contains(msg, strconv.FormatUint(geometry.MaxNewVolumeBytes, 10)) { + t.Fatalf("refusal does not name the maximum: %q", msg) + } + if _, ok := m.Lifecycle().Volumes.GetVolume("over-max"); ok { + t.Fatal("a refused volume has a lifecycle record") + } +} diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index 01e9fa3156..d8b20c3644 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -159,7 +159,7 @@ func (s *FileStore) CreateVolume(spec VolumeSpec) (VolumeRecord, error) { } return existing, nil } - if err := geometry.ValidateVolumeSize(spec.SizeBytes); err != nil { + if err := geometry.ValidateNewVolumeSize(spec.SizeBytes); err != nil { return VolumeRecord{}, fmt.Errorf("%w: %w", ErrInvalidVolumeSpec, err) } if err := validateSpec(spec); err != nil { diff --git a/seaweed-block/core/lifecycle/volume_size_limit_test.go b/seaweed-block/core/lifecycle/volume_size_limit_test.go index 7aa7627f55..208ecd6467 100644 --- a/seaweed-block/core/lifecycle/volume_size_limit_test.go +++ b/seaweed-block/core/lifecycle/volume_size_limit_test.go @@ -2,8 +2,11 @@ package lifecycle import ( "errors" + "strconv" "strings" "testing" + + "github.com/seaweedfs/seaweed-block/core/geometry" ) func TestCreateVolumeRejectsBeyondUint32LBACap(t *testing.T) { @@ -11,13 +14,13 @@ func TestCreateVolumeRejectsBeyondUint32LBACap(t *testing.T) { if err != nil { t.Fatal(err) } - const capBytes = uint64(17592186040320) // 16 TiB - 4 KiB + const capBytes = geometry.MaxNewVolumeBytes // at most 16 TiB - 4 KiB (uint32 LBA) if _, err = s.CreateVolume(VolumeSpec{VolumeID: "at-cap", SizeBytes: capBytes, ReplicationFactor: 1}); err != nil { t.Fatal(err) } for _, size := range []uint64{capBytes + 1, capBytes + 4096, ^uint64(0)} { _, err = s.CreateVolume(VolumeSpec{VolumeID: "too-large", SizeBytes: size, ReplicationFactor: 1}) - if !errors.Is(err, ErrInvalidVolumeSpec) || !strings.Contains(err.Error(), "16 TiB - 4 KiB") { + if !errors.Is(err, ErrInvalidVolumeSpec) || !errors.Is(err, geometry.ErrVolumeTooLarge) || !strings.Contains(err.Error(), strconv.FormatUint(geometry.MaxNewVolumeBytes, 10)) { t.Fatalf("size %d: want clear capacity refusal, got %v", size, err) } if _, ok := s.GetVolumeSnapshot("too-large"); ok { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 918726656c..d60d7f1b99 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -902,6 +902,7 @@ Notes: | `INV-HOST-URGENT-PENDING-001` | While an urgent cut holds its slot, or a caller holds HoldUrgentPending, every Normal admission on the host is refused with ErrUrgentPending (a held-slot wait); urgent admissions still run. | M7 host cut admission (Normal before a slot) | `core/hostlimit/limiter.go` `pool`, `Admit`; `core/hostlimit/pending.go` `HoldUrgentPending` | `TestNormalWaitsWhileUrgentPendingIsHeld`, `TestUrgentLeaseHoldsThePendingSignal` (`core/hostlimit/pending_test.go`); `TestSlotsUrgentAndJoinedRelease` (`core/hostlimit/limiter_test.go`) | — | ACTIVE | | `INV-HOST-LAUNCH-CHECK-001` | blockvolume refuses to start with a --host-limit-dir that is missing or not a directory, under a temporary directory, on a network file system, or already in use with different host-limit flags. | M7 host cut admission (process start) | `core/hostlimit/launch.go` `CheckLaunch`; `core/hostlimit/remotefs_linux.go`; `cmd/blockvolume/main.go` | `TestCheckLaunch` (`core/hostlimit/pending_test.go`) | — | ACTIVE | | `INV-LOCAL-HEADROOM-001` | blockvolume refuses to create a volume when the durable root's free space is below the volume size plus its WAL, naming both numbers, before it creates the store, WAL or fresh marker, and warns at start when an existing volume's remaining sparse growth plus the WAL exceed the free space. | M1 open/create (durable provider start) | `core/frontend/durable/headroom.go`; `core/frontend/durable/provider.go` `createFresh`, `openExisting` | `TestCreateRefusesWithoutLocalHeadroom`, `TestOpenWarnsWithoutLocalHeadroom` (`core/frontend/durable/headroom_test.go`) | — | ACTIVE | +| `INV-CREATE-MAX-SIZE-001` | blockmaster refuses a new volume above `geometry.MaxNewVolumeBytes` at CreateVolume (InvalidArgument) and at a `--cluster-spec` start, with `ErrVolumeTooLarge` naming the size and the maximum, before any record or store exists. An existing volume keeps opening under `MaxVolumeBytes`. | create admission (CreateVolume, cluster-spec import) | `core/geometry/volume_size.go` `ValidateNewVolumeSize`; `core/lifecycle/store.go` `CreateVolume`; `cmd/blockmaster/cluster_spec.go` `loadClusterSpec`; `core/host/master/services.go` `CreateVolume` (restore geometry) | `TestCreateVolumeRefusesAVolumeAboveTheMaximum` (`core/host/master`), `TestClusterSpecRefusesAVolumeAboveTheMaximum` (`cmd/blockmaster`), `TestValidateNewVolumeSizeAtAndAboveTheMaximum` (`core/geometry`), `TestCreateVolumeRejectsBeyondUint32LBACap` (`core/lifecycle`) | — | ACTIVE | | `INV-HOST-SLOT-BUSY-CODE-001` | The chunk control API refuses a cut, snapshot or detach that host admission refused because every slot is held (or urgent work is pending) with 503 host_slot_busy, retryable; every other capture refusal keeps capture_refused. | M7 free → admitted (refused, wait) | `core/host/volume/chunk_control.go` `chunkErrorCode` | `TestHostSlotHeldHasItsOwnCode` (`core/host/volume/chunk_host_slot_code_test.go`) | — | ACTIVE | | `INV-CUT-INTENT-FIRST-001` | Before the first chunk or segment PUT of a cut or staging round, the holder's session is begun (Begin; a replay while it is open): one Begin per round, however many upload waves it uses; every object the cut writes belongs to that session until its commit. | M5 Begin → Upload → CAS | `core/storage/chunk_cut_payload.go` `streamCutPayloads`; `core/storage/chunk_layer.go` `captureLocked`, `stage`; `core/frontend/chunkstore/layout_remote.go` `LayoutRemote.Begin` | `TestSession_BegunBeforeFirstUploadAndClosedByCommit`, `TestSession_FailedBeginUploadsNothing` (`core/storage/chunk_layer_session_test.go`); `TestCutPayloadSessionBeginsIndependentOfCandidates`, `TestCutPayloadReadsOverlapEarlierUploadsWithinBudget` (`core/storage/chunk_review271_test.go`); `TestChunkPrecopy_StagedUploadsAreCoveredByIntents` (`core/storage/chunk_layer_precopy_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `WorkspaceTakeover` `NoLiveIntentExpired` | ACTIVE | | `INV-CUT-INTENT-CLOSE-001` | The session lives as long as the staged uploads: it is aborted only when they are dropped (Close, fenced, a HEAD moved past the commit's base, a settled proposal), never while a proposal's commit is unresolved; a refused cut that keeps its uploads keeps its session for the retry. | M5 Close | `core/storage/chunk_layer.go` `Close`, `captureLocked`, `discardStaged`, `requeueCut` | `TestChunkCloseAbortsTheOpenSessionUnlessACommitIsUnresolved` (`core/storage/chunk_review271_test.go`); `TestSession_AdmissionRefusedBeforeCommitKeepsReusableUploads` (`core/storage/chunk_layer_session_test.go`); `TestHeadBeltOldCASUnconfirmedKeepsSessionAndFrontier`, `TestHeadBeltLowerEpochConflictFencesWithoutCleanup`, `TestHeadBeltEmptyBaseForeignPublicationFences` (`core/storage/chunk_head_belt_test.go`) | — | ACTIVE | From 57cfe0827f8cb0cb4329356ce328ab66df235a08 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 27 Nov 2026 18:04:50 -0800 Subject: [PATCH 2/4] test: max volume size boundary at one block above, at both doors Co-Authored-By: Claude Opus 5.5 --- .../blockmaster/cluster_spec_max_size_test.go | 3 +- .../core/geometry/volume_size_new_test.go | 6 ++-- .../core/host/master/max_volume_size_test.go | 29 ++++++++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go b/seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go index b3ae9588df..1994f5807c 100644 --- a/seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go +++ b/seaweed-block/cmd/blockmaster/cluster_spec_max_size_test.go @@ -12,7 +12,7 @@ import ( ) // The cluster spec is read before blockmaster starts serving: a volume of -// exactly MaxNewVolumeBytes is imported, one chunk more refuses the start +// exactly MaxNewVolumeBytes is imported, one block or one chunk more refuses the start // with an error naming the volume and the maximum. func TestClusterSpecRefusesAVolumeAboveTheMaximum(t *testing.T) { for _, c := range []struct { @@ -21,6 +21,7 @@ func TestClusterSpecRefusesAVolumeAboveTheMaximum(t *testing.T) { ok bool }{ {"at the maximum", geometry.MaxNewVolumeBytes, true}, + {"one block above", geometry.MaxNewVolumeBytes + 4096, false}, {"one chunk above", geometry.MaxNewVolumeBytes + 4<<20, false}, } { t.Run(c.name, func(t *testing.T) { diff --git a/seaweed-block/core/geometry/volume_size_new_test.go b/seaweed-block/core/geometry/volume_size_new_test.go index 8a247295ad..e8c787a58a 100644 --- a/seaweed-block/core/geometry/volume_size_new_test.go +++ b/seaweed-block/core/geometry/volume_size_new_test.go @@ -12,7 +12,9 @@ func TestValidateNewVolumeSizeAtAndAboveTheMaximum(t *testing.T) { if err := ValidateNewVolumeSize(MaxNewVolumeBytes); err != nil { t.Fatalf("at the maximum: %v", err) } - if err := ValidateNewVolumeSize(MaxNewVolumeBytes + 4<<20); !errors.Is(err, ErrVolumeTooLarge) { - t.Fatalf("one chunk above: %v, want ErrVolumeTooLarge", err) + for _, by := range []uint64{4096, 4 << 20} { + if err := ValidateNewVolumeSize(MaxNewVolumeBytes + by); !errors.Is(err, ErrVolumeTooLarge) { + t.Fatalf("%d bytes above: %v, want ErrVolumeTooLarge", by, err) + } } } diff --git a/seaweed-block/core/host/master/max_volume_size_test.go b/seaweed-block/core/host/master/max_volume_size_test.go index fbc6fdfa99..53cba3806d 100644 --- a/seaweed-block/core/host/master/max_volume_size_test.go +++ b/seaweed-block/core/host/master/max_volume_size_test.go @@ -17,8 +17,9 @@ import ( ) // CreateVolume, through the master's gRPC service as production serves it, -// creates a volume of exactly MaxNewVolumeBytes and refuses one chunk more -// with InvalidArgument naming the maximum; the refused id gets no record. +// creates a volume of exactly MaxNewVolumeBytes and refuses one block (4 KiB) +// or one chunk (4 MiB) more with InvalidArgument naming the maximum; a +// refused id gets no record. func TestCreateVolumeRefusesAVolumeAboveTheMaximum(t *testing.T) { m, err := New(Config{Listen: "127.0.0.1:0", AuthorityStoreDir: t.TempDir(), LifecycleStoreDir: t.TempDir(), WorkspaceRPC: true, LayoutCreateVolume: testLayoutCreateVolume, WorkspaceHeadReader: func(context.Context, string) (authority.WorkspaceHead, error) { return authority.WorkspaceHead{}, nil }}) @@ -39,14 +40,20 @@ func TestCreateVolumeRefusesAVolumeAboveTheMaximum(t *testing.T) { if _, err := lc.CreateVolume(ctx, &control.CreateVolumeRequest{VolumeId: "at-max", SizeBytes: geometry.MaxNewVolumeBytes, ReplicationFactor: 1}); err != nil { t.Fatalf("a volume of exactly the maximum (%d bytes) is refused: %v", geometry.MaxNewVolumeBytes, err) } - _, err = lc.CreateVolume(ctx, &control.CreateVolumeRequest{VolumeId: "over-max", SizeBytes: geometry.MaxNewVolumeBytes + 4<<20, ReplicationFactor: 1}) - if status.Code(err) != codes.InvalidArgument { - t.Fatalf("one chunk above the maximum: got %v, want InvalidArgument", err) - } - if msg := status.Convert(err).Message(); !strings.Contains(msg, geometry.ErrVolumeTooLarge.Error()) || !strings.Contains(msg, strconv.FormatUint(geometry.MaxNewVolumeBytes, 10)) { - t.Fatalf("refusal does not name the maximum: %q", msg) - } - if _, ok := m.Lifecycle().Volumes.GetVolume("over-max"); ok { - t.Fatal("a refused volume has a lifecycle record") + for _, over := range []struct { + name string + by uint64 + }{{"one block", 4096}, {"one chunk", 4 << 20}} { + id := "over-max-" + strconv.FormatUint(over.by, 10) + _, err = lc.CreateVolume(ctx, &control.CreateVolumeRequest{VolumeId: id, SizeBytes: geometry.MaxNewVolumeBytes + over.by, ReplicationFactor: 1}) + if status.Code(err) != codes.InvalidArgument { + t.Fatalf("%s above the maximum: got %v, want InvalidArgument", over.name, err) + } + if msg := status.Convert(err).Message(); !strings.Contains(msg, geometry.ErrVolumeTooLarge.Error()) || !strings.Contains(msg, strconv.FormatUint(geometry.MaxNewVolumeBytes, 10)) { + t.Fatalf("%s above: refusal does not name the maximum: %q", over.name, msg) + } + if _, ok := m.Lifecycle().Volumes.GetVolume(id); ok { + t.Fatalf("%s above: a refused volume has a lifecycle record", over.name) + } } } From 586f7e442d73c038503be9fb714efe1b16f0a4bf Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 27 Nov 2026 18:36:43 -0800 Subject: [PATCH 3/4] fix: new volumes are at most 256 GiB in v1.0.0 MaxNewVolumeBytes is 256 GiB (65,536 chunks of 4 MiB), derived from the measured number of chunks a commit checks within one 2 s update of HEAD, halved and rounded down. The release note states the limit, why, that a restore target takes its source's size, and that it is planned to be removed in 1.0.1. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/geometry/volume_size.go | 11 ++++++++--- seaweed-block/docs/releases/v1.0.0.md | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/geometry/volume_size.go b/seaweed-block/core/geometry/volume_size.go index 6263383459..9259c2afca 100644 --- a/seaweed-block/core/geometry/volume_size.go +++ b/seaweed-block/core/geometry/volume_size.go @@ -15,9 +15,14 @@ const MaxVolumeBytes uint64 = (16 << 40) - 4096 // and a cluster spec's volumes). It is checked only where a volume is // created, so a volume that already exists keeps opening under // MaxVolumeBytes. A restore target takes its source's size. -// Placeholder value: MaxVolumeBytes, until it is set from the measured -// capacity limit. -const MaxNewVolumeBytes uint64 = MaxVolumeBytes +// +// 256 GiB is 65,536 chunks of 4 MiB. A cut's commit checks the chunks it +// names within one 2 s conditional update of HEAD; the worst of five +// measured runs verified about 188,000 chunks in that time at 32 requests +// in flight. Halved for the rest of the update (the HEAD write, the +// manifest segments, a loaded or remote filer) and rounded down to a power +// of two, that is 65,536 chunks. +const MaxNewVolumeBytes uint64 = 256 << 30 // ErrVolumeTooLarge refuses a new volume above MaxNewVolumeBytes. var ErrVolumeTooLarge = errors.New("volume too large") diff --git a/seaweed-block/docs/releases/v1.0.0.md b/seaweed-block/docs/releases/v1.0.0.md index c4e300296b..8bdf3e93c4 100644 --- a/seaweed-block/docs/releases/v1.0.0.md +++ b/seaweed-block/docs/releases/v1.0.0.md @@ -64,6 +64,10 @@ defaults, so a pod whose holder does not come back holds I/O for about 600 s whe blockmaster reads volume HEADs through its SeaweedFS filer connection (`--chunk-filer`). ## Limits +- New volumes are at most 256 GiB (65,536 chunks of 4 MiB) in v1.0.0. A cut's commit checks the chunks it names + within one 2 s update of HEAD, and larger volumes were not measured to fit. CreateVolume refuses a larger size + (`InvalidArgument`, `volume too large`, naming the maximum), and blockmaster refuses to start with a `--cluster-spec` + volume above it. A restore target takes its source's size. The limit is planned to be removed in 1.0.1. - Up to 10 snapshots per volume; one more is refused with `snapshot_limit` and changes nothing (delete a snapshot or let retention prune). - A snapshot takes about 2 s per GiB changed since the last cut (64 GiB: 122 s). The CLI waits 60 s by default and From be8df1f354eb95eb8980c66a7b021ef6e97e3a2a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 27 Nov 2026 18:39:34 -0800 Subject: [PATCH 4/4] docs: the 256 GiB limit assumes a filer round trip under about 1 ms Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/releases/v1.0.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seaweed-block/docs/releases/v1.0.0.md b/seaweed-block/docs/releases/v1.0.0.md index 8bdf3e93c4..489de6a43a 100644 --- a/seaweed-block/docs/releases/v1.0.0.md +++ b/seaweed-block/docs/releases/v1.0.0.md @@ -68,6 +68,10 @@ defaults, so a pod whose holder does not come back holds I/O for about 600 s whe within one 2 s update of HEAD, and larger volumes were not measured to fit. CreateVolume refuses a larger size (`InvalidArgument`, `volume too large`, naming the maximum), and blockmaster refuses to start with a `--cluster-spec` volume above it. A restore target takes its source's size. The limit is planned to be removed in 1.0.1. +- The 256 GiB limit assumes a filer lookup round trip under about 1 ms (measured with the filer on the volume's + host): 65,536 lookups at 32 in flight fit in 2 s only below about 0.98 ms each, so a filer one network hop away is + at that edge. With a remote filer, use smaller volumes, or periodic cuts (`--chunk-capture-interval`) so that each + commit names fewer chunks. - Up to 10 snapshots per volume; one more is refused with `snapshot_limit` and changes nothing (delete a snapshot or let retention prune). - A snapshot takes about 2 s per GiB changed since the last cut (64 GiB: 122 s). The CLI waits 60 s by default and