Files
seaweedfs/seaweed-block
pingqiuandClaude Opus 5.5 d6ef70d2fe fix(sw-block): mini binds weed to loopback, owns every port and its dir, and watches all children
Review follow-up. weed mini gets -ip.bind=127.0.0.1 (its -ip alone is the
advertised address; the bind defaulted to 0.0.0.0), every listener's port
explicitly (master, volume and filer HTTP and gRPC), all preflighted and
moved by --port-shift, and its S3, WebDAV and admin UI off. --size refuses
an overflowing value. The dir is claimed by one exclusive mkdir (or must
exist with --reuse) and held by a lock for the run, before any write.
Startup and the layout id wait stop at once when any child dies.

Tests: the supported commands pinned value for value, with controls; a
busy weed port; port shift; one mini per dir; weed dying during startup;
the process tests register their bounded cleanup before any assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 13:47:39 -08:00
..
2026-04-11 14:21:09 -07:00

Seaweed Block

Block storage written in Go: a local-speed block device whose ownership is fenced by epochs. It serves agent workspace disks backed by SeaweedFS snapshots, and Kubernetes block volumes (alpha).

Seaweed Block: a shared core (blockvolume with ublk, NVMe/TCP and iSCSI frontends and the walstore WAL engine, plus blockmaster as the epoch authority) used for agent workspace disks with chunk snapshots in SeaweedFS and for Kubernetes PVCs, with optional RF=2 or RF=3 replication

What it is

Agent workspace disks Kubernetes block volumes
Consumer an agent sandbox or microVM, as a plain virtio block device an app pod, through a PVC and the CSI driver
Frontend NVMe/TCP loopback or ublk iSCSI, or NVMe/TCP (source-gated)
Durability one local replica, with cuts to SeaweedFS RF=1 with best-effort ack by default; synchronous RF=2 or RF=3 (sync-quorum, sync-all) when configured, in a supported lab
Maturity v1.0.0, single replica alpha

Both uses share one core. blockvolume serves one volume replica; its frontends turn block requests into a single Read / Write / Sync contract, and Sync is the only durability point. Writes land in a local WAL engine, walstore (a WAL plus an extent). blockvolume --durable-impl defaults to auto: a new volume is created as walstore and an existing one opens with its on-disk format; auto refuses a walstore-chunk root, which needs --durable-impl=walstore-chunk with its remote configuration. smartwal is experimental. blockmaster is the only component that mints epochs. Each blockvolume admits I/O only while its local view of the assignment is current: a deposed primary refuses I/O once it observes the new assignment or a fence, or once its workspace lease expires. That is a local admission rule, not an instant global revocation. Separately, every remote HEAD publish is a conditional update on {gen, epoch}, so the store refuses a stale holder's publish even before that holder notices it was replaced. The design is in three documents: the core design, the agent workspace design and the Kubernetes block design. Each covers its parts, their invariants, the tests behind them and the known issues.

Highlights

Agent workspace disks

  • Local-speed disk. Writes and fsync complete against the local WAL; nothing on the write path waits on the network.
  • Incremental snapshots. A cut uploads only the changed 4 MiB chunks. Chunks are immutable; the volume's state is a HEAD root of about 2 KB, and every publish is a conditional update on {gen, epoch}.
  • Cheap snapshot and restore. A snapshot copies only the HEAD root; chunks are shared. A restore makes a new volume that reads the snapshot's chunks. The holder's cleaning removes the chunks that no snapshot, restore target or current image names; SeaweedFS vacuum then returns the space.
  • Move to any host. Another host takes over with a higher epoch and fetches chunks lazily on first read. A stale holder cannot publish.
  • Single replica by design. Losing a host loses at most the writes since the last cut. Cut at semantic points: after an agent step, before a risky command, on detach.

Kubernetes block volumes (alpha): Helm install, dynamic PVCs, RF=3 recovery gates in a supported lab, support-bundle replay, and negative-first read-only status (stale evidence is Ready=Unknown, never a false ready).

Measured results

Lab runs, median of 3; not SLOs. Workloads: Firecracker microVMs (4 vCPU, 4 GiB) on one bare-metal host over NVMe/TCP loopback, against a local file-backed disk. The two fsync rows marked "ublk" come from a later run on the same host with the ublk frontend, after the group-commit fix (#173). For the snapshot row: a host-side proxy without network latency, guest fsync or the block frontend. The two-host lifecycle row is a pre-release run that included fork (removed from this release) and the earlier GC.

Measurement Seaweed Block Local disk
npm ci (617 packages, offline) / git clone (Go 1.23, local) 2.14 s / 7.10 s 2.14 s / 6.99 s
Untar 100,000 files / cold find + stat over them 1.10 s / 0.32 s 1.06 s / 0.33 s
2,000 × create + write + fsync (ublk) 8.48 s 6.11 s
Guest fsync median, fio 4 KiB random write, one at a time (ublk) 3.23 ms 2.74 ms
Snapshot of a 10 GiB volume (2,560 chunks) 0.18 ms
Two-host lifecycle (pre-release): create, snapshot, fork, move, stale holder, delete, GC 35 of 35 checks

Metadata-heavy workloads run at local-disk speed. The remaining cost is fsync: a median of 3.23 ms against 2.74 ms local with the ublk frontend (3.59 ms over NVMe/TCP loopback), down from about 7 ms before the group-commit fix. Every guest fsync still reaches the backend sync; no write cache is turned off to get there. Workspace measurements has every number and how each was measured.

Install

The binaries are blockmaster, blockvolume and the sw-block CLI. The commands on this page are for v1.0.0. Option 1: copy them from the v1.0.0 image, ghcr.io/seaweedfs/seaweed-block:v1.0.0 (index digest sha256:648980beb519a086349d44367e9d19ba6ae94b8939456ae3eb7b7bb5e4b3b28b):

docker create --name swb-extract ghcr.io/seaweedfs/seaweed-block:v1.0.0
for b in blockmaster blockvolume sw-block; do docker cp swb-extract:/usr/local/bin/$b .; done
docker rm swb-extract && ./blockvolume --version

Option 2: build from the tag v1.0.0 (the Go version in go.mod):

git clone --branch v1.0.0 https://github.com/seaweedfs/seaweed-block && cd seaweed-block
for b in blockmaster blockvolume sw-block; do go build -o $b ./cmd/$b; done

Option 3: Helm, see the Kubernetes quick start. Services: standalone deployment. Operator guide (supported setup, sizing, recovery point, host loss, limits): operator guide.

Try it

The first volume check starts blockmaster and one blockvolume, attaches a 256 MiB volume over NVMe/TCP on loopback, shows the device and its status, and stops. It does not format or write the attached device; it only creates local backing files and logs. It needs Linux, bash, nvme-cli, sudo and the binaries above. To format and write, use the write test (scratch host only).

Agent workspace disks: chunk lifecycle

The workspace path runs blockvolume with --durable-impl=walstore-chunk, --chunk-filer <filer> and --chunk-control-endpoint, against a SeaweedFS cluster. The sw-block ops chunk commands drive the lifecycle:

sw-block ops chunk cut       --volume v1 --status-addr <status>  # publish changed chunks, advance HEAD
sw-block ops chunk snapshot  --volume v1 --status-addr <status> --name s1   # name a snapshot
sw-block ops chunk snapshots --master <blockmaster> --volume v1 --chunk-filer <filer>   # list snapshots
sw-block ops chunk restore   --master <blockmaster> --chunk-filer <filer> --source v1 --snapshot s1 --target v3  # new volume from a snapshot
sw-block ops chunk detach    --volume v1 --status-addr <status>  # final cut (seal); moving needs revoke + move, see docs/volume-lifecycle.md
sw-block ops chunk volume-delete --volume v3 --chunk-filer <filer> --master <blockmaster> --request-id del-v3

volume-delete is refused until the volume's holder has been revoked and its ACK is recorded, and while the volume has snapshots: see Delete a volume. Frozen detach and the pre-copy detach are not supported in this release: a detach with --frozen (frozen:true on POST /chunk/detach) is refused with 409 frozen_detach_unsupported, and blockvolume refuses to start with --chunk-detach-precopy. restore creates the target from the snapshot; its blockvolume serves at once and reads every chunk it has not made local from the source's snapshot (there is no background copy). The source snapshot cannot be deleted while the target exists. Fork is not supported in this release; the command is removed. See Restoring a snapshot. In v1.0.0 the chunk path (walstore-chunk) is the supported single-replica configuration (release note, operator guide); it is not the --durable-impl default.

Quick start: Kubernetes (alpha)

For supported lab clusters, not production. From the repository root, with kubectl and helm configured:

go build -o sw-block ./cmd/sw-block && export PATH="$PWD:$PATH"
sw-block ops generate-helm-values --out values.day1.yaml \
  --image ghcr.io/seaweedfs/seaweed-block:sha-dc2972d0059b \
  --csi-image ghcr.io/seaweedfs/seaweed-block-csi:sha-dc2972d0059b
helm install sw-block charts/seaweed-block --namespace kube-system \
  --create-namespace -f values.day1.yaml --wait --timeout 10m
SW_BLOCK_INSTALL_MODE=helm SW_BLOCK_HELM_RELEASE=sw-block \
SW_BLOCK_HELM_NAMESPACE=kube-system SW_BLOCK_HELM_VALUES_FILE=values.day1.yaml \
  bash scripts/run-basic-app-example.sh "$PWD"

The last command writes a PVC from one pod and reads it from a replacement pod; expect first_volume_status=ok in /tmp/sw-block-basic-app-*/first-volume-summary.txt. sha-dc2972d0059b is the validated tag for the v0.4 read-only status path; later paths need matching release images, and :alpha is for smoke tests only. Each step's output is in the Kubernetes quickstart. To clean up:

helm uninstall sw-block --namespace kube-system
bash scripts/uninstall-k8s-alpha.sh "$PWD" && bash scripts/verify-helm-cleanup.sh

Status

Area Status
Agent workspace disks (walstore-chunk), single replica Supported in v1.0.0; see its known limits
Replicated volumes (replication_factor above 1) Preview in v1.0.0 (replicated volumes preview)
Kubernetes: Helm install, PVC provisioning, writer/reader check, read-only report and dashboard, CRD status and Events, support-bundle replay Available (alpha)
Kubernetes: RF=3 multi-volume, CSI reattach recovery, iSCSI ALUA/dm-multipath mounted failover, restart persistence with hostPath Gated (supported lab)
Kubernetes: SwBlockVolume finalizer lifecycle owner, returned-replica ACK eligibility executor Beta candidate
Kubernetes: NVMe/TCP CSI multipath, returned-replica failback runtime, WAL multi-block record opt-in Source-gated
Kubernetes: backup, snapshot and restore; returned-replica rebuild traffic Planned

Full table and conditions: Kubernetes status; run evidence: release notes.

Upgrade note: blockmaster listens off loopback only with mutual TLS (--tls-cert, --tls-key, --tls-client-ca, --role-file); the runtime HTTP listener always stays on loopback, and --insecure-external-bind is refused. The Helm chart and the shipped manifests run with mutual TLS; create their Secrets first (quickstart).

Not claimed yet

  • Production readiness, SLOs, or a published performance, RTO or RPO claim.
  • fsync parity with local disk. Today it is about 1.2× local (see Measured results).
  • ublk at high density. Unprivileged per-volume servers need a privileged control broker, which is not done.
  • Crash-restart recovery of a ublk server. A crashed server fails closed.
  • Multi-replica workspaces combined with chunk snapshots.
  • The smartwal engine, which is experimental: no rollback for a torn in-place overwrite, no per-block CRC once its ring record recycles, open handling of a corrupted committed record, and no chunk snapshots.
  • Kubernetes: backup and restore, a production operator, automatic failback or cleanup, upgrade execution, broad compatibility, and more: see what you should not expect yet.

Correctness and verification

  • CI runs go build, go vet and go test -short on every pull request and push to main (workflow); that set leaves out the four long, disk-heavy packages (a pull request runs those of them it changes); they run in full, together with the legacy-fixture configuration, on a separate test VM for every merge train (commit status full-suite (pool VM) on the train head). Crash, mutation, real-SeaweedFS and binary tests are described in the core design, Part 2, with the known issues.
  • Formal models: TLA+ specifications of the protocols where a bug would lose data. Counterexamples became fixes and regression tests (#152, #156, #158, #159).
  • Fail closed: recovery that cannot establish a consistent image reports a typed reason (wal_corrupt, io_error) instead of serving; some suspected damage (wal_hole_suspected) is a status warning only.

Documentation

Development

go build ./... && go vet ./... && go test -short ./...    # what CI runs
go test ./cmd/sw-block ./core/ops ./core/csi ./core/launcher ./core/host/master -count=1  # release-scoped

The full go test ./... sweep may include in-progress packages outside the release gate. scripts/activate-k8s-alpha.sh remains for local images.

License

Apache-2.0