From 781e842ef196af0c3aaf91f4e99a93da7ff35840 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 20 Nov 2026 01:06:31 -0800 Subject: [PATCH] test(storage): expose syscall probe and record sync contract --- .../core/storage/data_sync_linux_test.go | 27 +++++++++++++++++++ seaweed-block/docs/design/invariants.md | 6 +++++ 2 files changed, 33 insertions(+) diff --git a/seaweed-block/core/storage/data_sync_linux_test.go b/seaweed-block/core/storage/data_sync_linux_test.go index 0e2c28eeed..9643077fe5 100644 --- a/seaweed-block/core/storage/data_sync_linux_test.go +++ b/seaweed-block/core/storage/data_sync_linux_test.go @@ -151,3 +151,30 @@ func TestFdatasyncAcknowledgedWritesSurviveSIGKILL(t *testing.T) { } } } + +// Run under strace with the experiment environment unset/set to verify the +// syscall boundary independently of the selected function's Go identity. +func TestDataSyncSyscallProbe(t *testing.T) { + s, e := CreateWALStore(filepath.Join(t.TempDir(), "volume"), 32, 4096) + if e != nil { + t.Fatal(e) + } + defer s.Close() + s.DisableAutoFlushForRecoveryTest() + if _, e = s.Recover(); e != nil { + t.Fatal(e) + } + if _, e = s.Write(7, bytes.Repeat([]byte{0x6d}, 4096)); e != nil { + t.Fatal(e) + } + if _, e = s.Sync(); e != nil { + t.Fatal(e) + } + if e = s.flusher.flushOnce(); e != nil { + t.Fatal(e) + } + b, e := s.Read(7) + if e != nil || !bytes.Equal(b, bytes.Repeat([]byte{0x6d}, 4096)) { + t.Fatalf("readback: %v", e) + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 9068b36a7b..7c12d9c6bd 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -527,6 +527,12 @@ Notes: |---|---|---|---|---|---|---| | `INV-NVME-H2C-RANGE-001` | An H2CData range exceeding the expected transfer size is refused before slicing, including a uint32 offset-plus-length overflow; an exact-bound payload is preserved. | Frontend H2C receive validation; no storage state transition | `core/frontend/nvme/session.go` `recvH2CData` | `TestRecvH2CDataRangeBounds` (`core/frontend/nvme/h2c_bounds_test.go`) | — | ACTIVE | +### Experimental data-file synchronization + +| ID | Invariant | Machine / transition | Enforced in | Tests | TLA+ | Status | +|---|---|---|---|---|---|---| +| `INV-WAL-DATA-SYNC-001` | Default WAL/extent sync remains fsync. Linux `SWBLOCK_SYNC=fdatasync` selects data-only sync for WAL/extent data; descriptor/map/create/directory durability still uses fsync. `SWBLOCK_PREZERO=1` writes every byte only at create, fsyncs, then refuses holes/unwritten FIEMAP mappings. Existing files are never prezeroed. | M1 Create / Sync / Checkpoint | `data_sync.go`, `data_sync_linux.go`; `walstore_v3.go` Create; `walstore.go` data sync seams | `TestPrezeroCreatesInitializedVolume`, `TestInitializedFileRejectsSparseAndUnwritten`, `TestFdatasyncAcknowledgedWritesSurviveSIGKILL`, `TestDataSyncSyscallProbe` (`core/storage/data_sync_linux_test.go`) | Same abstract durable sync action; syscall/extent initialization and process-crash versus power-loss limits are outside the model | ACTIVE | + ## Part C. Change rules How a fix or a feature is calibrated against this model: