phase163: add standalone nvme rdma live path

This commit is contained in:
pingqiu committed 2026-07-18 01:07:05 -07:00
1 parent 1881dc772b
commit ab0930c399
20 files changed
+1736 -234

No files matched your search

+8 -4
View File
@@ -87,9 +87,11 @@ This is an **alpha** product path for supported lab clusters, not production.
record opt-in has mounted profile and restart/recovery compatibility evidence,
plus mounted durable-status `HeadLSN` confirmation, but remains default-off
and requires a future matching-image release smoke before it becomes a public
image claim. This is a
supported-lab source-gated claim, not a broad NVMe
compatibility, RoCE/NVMe-RDMA, production HA, or performance/SLO claim.
image claim. A separate source-gated standalone Linux gate now proves a
standard `nvme connect -t rdma` write/read/flush path through the Seaweed
backend on the supported RoCE lab. RDMA is not yet published through CSI.
These are supported-lab source-gated claims, not broad NVMe compatibility,
production HA, or performance/SLO claims.
- Replay support bundles offline.
These are narrow alpha claims tied to documented gates. See
@@ -111,7 +113,9 @@ These are narrow alpha claims tied to documented gates. See
- Broad NVMe/RoCE compatibility, performance/SLO, or transparent failover
parity beyond the documented supported-lab gates. The CSI-node reconnect
owner, host-path reconnect gate, desired path-set replacement gate, and
stale path pruning gate exist only as source-gated supported-lab evidence.
stale path pruning gate exist only as source-gated NVMe/TCP evidence. The
NVMe/RDMA path is standalone-only until its lifecycle hardening and
Kubernetes publish/attach gates pass.
- Broad distro/kernel/initiator compatibility.
- Upgrade or rollback execution. The status layer can report install drift, but
it does not run Helm or kubectl mutations.
@@ -5,6 +5,7 @@ import (
"testing"
"time"
"github.com/seaweedfs/seaweed-block/core/frontend/nvmerdma"
"github.com/seaweedfs/seaweed-block/core/host/volume"
)
@@ -45,18 +46,42 @@ func TestParseFlags_NVMeTransportDefaultsTCP(t *testing.T) {
}
}
func TestParseFlags_NVMeTransportRejectsRDMA(t *testing.T) {
func TestParseFlags_NVMeTransportAcceptsExplicitRDMA(t *testing.T) {
args := append(requiredBlockvolumeArgs(),
"--nvme-listen", "127.0.0.1:4420",
"--nvme-listen", "10.0.0.3:4420",
"--nvme-subsysnqn", "nqn.2026-05.io.seaweedfs:test-v1",
"--nvme-transport", "rdma",
"--allow-external-nvme-bind",
)
got, err := parseFlags(args)
if err != nil {
t.Fatalf("parseFlags: %v", err)
}
if got.nvmeTransport != "rdma" {
t.Fatalf("nvmeTransport=%q want rdma", got.nvmeTransport)
}
}
func TestParseFlags_NVMERDMARejectsTCPMaxH2COption(t *testing.T) {
args := append(requiredBlockvolumeArgs(),
"--nvme-listen", "10.0.0.3:4420",
"--nvme-subsysnqn", "nqn.2026-05.io.seaweedfs:test-v1",
"--nvme-transport", "rdma",
"--allow-external-nvme-bind",
"--nvme-max-h2c-data-length", "65536",
)
_, err := parseFlags(args)
if err == nil {
t.Fatal("parseFlags succeeded; want rdma transport rejected")
if err == nil || !strings.Contains(err.Error(), "applies only to --nvme-transport=tcp") {
t.Fatalf("error=%v want TCP-only MaxH2C refusal", err)
}
if !strings.Contains(err.Error(), `--nvme-transport="rdma" unsupported`) {
t.Fatalf("error = %q, want unsupported transport", err)
}
func TestNVMERDMAStandaloneTargetIsNotPublishedToCSI(t *testing.T) {
if shouldPublishNVMeFrontendTarget("rdma") {
t.Fatal("standalone RDMA target must not enter master/CSI publish context")
}
if !shouldPublishNVMeFrontendTarget("tcp") {
t.Fatal("TCP target publication changed")
}
}
@@ -66,7 +91,7 @@ func TestNVMeFrontendCapabilitiesExposeRDMAUnsupportedNoListener(t *testing.T) {
Available: false,
Reason: "nvme_rdma_module_missing",
}}
caps := nvmeFrontendCapabilitiesWithRDMAPreflight("127.0.0.1:4420", true, facts)
caps := nvmeFrontendCapabilitiesWithRDMAPreflight("127.0.0.1:4420", "tcp", true, facts)
if len(caps) != 2 {
t.Fatalf("capabilities=%d want 2", len(caps))
}
@@ -75,7 +100,7 @@ func TestNVMeFrontendCapabilitiesExposeRDMAUnsupportedNoListener(t *testing.T) {
t.Fatalf("tcp capability unexpected: %+v", tcp)
}
rdma := caps[1]
if rdma.Protocol != "nvme" || rdma.Transport != "rdma" || rdma.Supported || rdma.ListenerImplemented || rdma.ListenerStarted || rdma.StartAllowed {
if rdma.Protocol != "nvme" || rdma.Transport != "rdma" || rdma.Supported || rdma.ListenerImplemented != nvmerdma.Implemented() || rdma.ListenerStarted || rdma.StartAllowed {
t.Fatalf("rdma capability must stay unsupported with no listener: %+v", rdma)
}
if rdma.Reason != "nvme_rdma_transport_unsupported" {
@@ -107,7 +132,29 @@ func TestNVMERDMAListenerStartDecisionMapsPreflightFailure(t *testing.T) {
}
}
func TestNVMERDMAListenerStartDecisionStillUnsupportedAfterPreflight(t *testing.T) {
func TestNVMERDMAListenerStartDecisionDoesNotRequireInitiatorModule(t *testing.T) {
got := nvmeRDMAListenerStartDecision(true, []volume.FrontendTransportPreflightFact{
{
Name: "nvme_rdma_module",
Available: false,
Reason: "nvme_rdma_module_missing",
},
{
Name: "nvmet_rdma_module",
Available: true,
Reason: "nvmet_rdma_module_available",
},
})
if nvmerdma.Implemented() {
if !got.allowed || got.reason != "implemented" {
t.Fatalf("start decision=%+v want target allowed without initiator module", got)
}
} else if got.allowed || got.reason != "nvme_rdma_transport_unsupported" {
t.Fatalf("start decision=%+v want unsupported platform", got)
}
}
func TestNVMERDMAListenerStartDecisionAfterPreflight(t *testing.T) {
got := nvmeRDMAListenerStartDecision(true, []volume.FrontendTransportPreflightFact{{
Name: "nvme_rdma_module",
Available: true,
@@ -121,8 +168,12 @@ func TestNVMERDMAListenerStartDecisionStillUnsupportedAfterPreflight(t *testing.
Available: true,
Reason: "rdma_bind_address_candidate",
}})
if got.allowed || got.reason != "nvme_rdma_transport_unsupported" {
t.Fatalf("start decision=%+v want unsupported implementation", got)
if nvmerdma.Implemented() {
if !got.allowed || got.reason != "implemented" {
t.Fatalf("start decision=%+v want implemented", got)
}
} else if got.allowed || got.reason != "nvme_rdma_transport_unsupported" {
t.Fatalf("start decision=%+v want unsupported platform", got)
}
}
+116 -55
View File
@@ -10,6 +10,7 @@ import (
"fmt"
"net"
"os"
"os/exec"
"os/signal"
"strconv"
"strings"
@@ -22,6 +23,7 @@ import (
"github.com/seaweedfs/seaweed-block/core/frontend/iscsi"
"github.com/seaweedfs/seaweed-block/core/frontend/memback"
"github.com/seaweedfs/seaweed-block/core/frontend/nvme"
"github.com/seaweedfs/seaweed-block/core/frontend/nvmerdma"
"github.com/seaweedfs/seaweed-block/core/host/volume"
"github.com/seaweedfs/seaweed-block/core/recovery"
"github.com/seaweedfs/seaweed-block/core/replication"
@@ -74,7 +76,7 @@ type flags struct {
iscsiCHAPSecret string
allowExternalISCSIBind bool
// NVMe/TCP frontend flags. Symmetric with iSCSI flags: same
// NVMe frontend flags. Symmetric with iSCSI flags: same
// loopback-only safe-default rule, same auto-enable of
// --t1-readiness so the symmetry stays clean.
nvmeListen string
@@ -82,7 +84,7 @@ type flags struct {
nvmeNS uint
nvmeTransport string
nvmeMaxH2C uint
// External NVMe/TCP bind is explicit because the current target has no
// External NVMe bind is explicit because the current target has no
// authentication. Phase 106 uses it for controlled Kubernetes cross-node
// gates; default installs remain loopback-only.
allowExternalNVMeBind bool
@@ -159,9 +161,9 @@ func parseFlags(args []string) (flags, error) {
fs.StringVar(&f.nvmeListen, "nvme-listen", "", "NVMe/TCP target bind address (e.g. 127.0.0.1:0); empty disables. Loopback-only (no auth)")
fs.StringVar(&f.nvmeSubsysNQN, "nvme-subsysnqn", "", "NVMe subsystem NQN (required if --nvme-listen is set)")
fs.UintVar(&f.nvmeNS, "nvme-ns", 1, "NVMe namespace id (default 1)")
fs.StringVar(&f.nvmeTransport, "nvme-transport", "tcp", "NVMe-oF transport. Only \"tcp\" is implemented; \"rdma\"/RoCE is a future gated feature")
fs.StringVar(&f.nvmeTransport, "nvme-transport", "tcp", "NVMe-oF transport: tcp or the explicit Linux-only standalone rdma target")
fs.UintVar(&f.nvmeMaxH2C, "nvme-max-h2c-data-length", 0, "NVMe/TCP MaxH2CDataLength in bytes. 0 preserves the target default")
fs.BoolVar(&f.allowExternalNVMeBind, "allow-external-nvme-bind", false, "allow NVMe/TCP to bind a non-loopback address; unauthenticated, intended only for explicit Kubernetes NVMe/TCP gates")
fs.BoolVar(&f.allowExternalNVMeBind, "allow-external-nvme-bind", false, "allow NVMe to bind a non-loopback address; unauthenticated, intended only for explicit gates")
fs.StringVar(&f.durableRoot, "durable-root", "", "directory for persistent storage files; empty = memback (non-durable)")
fs.StringVar(&f.durableImpl, "durable-impl", "smartwal", "LogicalStorage impl: smartwal (default) or walstore; ignored unless --durable-root is set")
fs.UintVar(&f.durableBlocks, "durable-blocks", 2048, "number of blocks per volume on first create (ignored when opening existing)")
@@ -275,8 +277,8 @@ func parseFlags(args []string) (flags, error) {
return flags{}, fmt.Errorf("--iscsi-chap-username/--iscsi-chap-secret require --iscsi-listen")
}
if f.nvmeListen != "" {
if f.nvmeTransport != "tcp" {
return flags{}, fmt.Errorf("--nvme-transport=%q unsupported; only \"tcp\" is implemented", f.nvmeTransport)
if f.nvmeTransport != "tcp" && f.nvmeTransport != "rdma" {
return flags{}, fmt.Errorf("--nvme-transport=%q unsupported; use \"tcp\" or \"rdma\"", f.nvmeTransport)
}
if f.nvmeSubsysNQN == "" {
return flags{}, fmt.Errorf("--nvme-subsysnqn is required when --nvme-listen is set")
@@ -287,6 +289,9 @@ func parseFlags(args []string) (flags, error) {
if f.nvmeMaxH2C > uint(^uint32(0)) {
return flags{}, fmt.Errorf("--nvme-max-h2c-data-length=%d exceeds uint32", f.nvmeMaxH2C)
}
if f.nvmeTransport == "rdma" && f.nvmeMaxH2C != 0 {
return flags{}, fmt.Errorf("--nvme-max-h2c-data-length applies only to --nvme-transport=tcp")
}
if err := nvme.ValidateMaxH2CDataLength(uint32(f.nvmeMaxH2C)); err != nil {
return flags{}, fmt.Errorf("--nvme-max-h2c-data-length=%d invalid: %w", f.nvmeMaxH2C, err)
}
@@ -488,7 +493,7 @@ func run(f flags) int {
if f.allowExternalStatusBind {
status.AllowExternalAccess()
}
status.SetFrontendCapabilities(nvmeFrontendCapabilities(f.nvmeListen, false))
status.SetFrontendCapabilities(nvmeFrontendCapabilities(f.nvmeListen, f.nvmeTransport, false))
bound, err := status.Start(f.statusAddr)
if err != nil {
fmt.Fprintln(os.Stderr, "blockvolume: status server:", err)
@@ -903,33 +908,51 @@ func run(f flags) int {
h.SetFrontendTargets(frontendTargets)
}
var nvmeTarget *nvme.Target
var nvmeTarget interface {
Start() (string, error)
Close() error
}
if f.nvmeListen != "" {
prov := provider
var probeProvider nvme.ProbeBackendProvider
if durableProv != nil {
probeProvider = &durableProbeProvider{provider: durableProv}
}
nvmeTarget = nvme.NewTarget(nvme.TargetConfig{
Transport: nvme.Transport(f.nvmeTransport),
Listen: f.nvmeListen,
SubsysNQN: f.nvmeSubsysNQN,
VolumeID: f.volumeID,
Provider: prov,
ProbeProvider: probeProvider,
ControllerID: nvmeControllerIDFromReplicaID(f.replicaID),
MaxH2CDataLength: uint32(f.nvmeMaxH2C),
// Capacity from durable config (see iSCSI block above).
// frontendBlockSize / frontendVolumeSize are 0 on memback
// path; nvme HandlerConfig zero-value defaulting preserves
// the historical 1 MiB / 512 B contract.
Handler: nvme.HandlerConfig{
if f.nvmeTransport == "rdma" {
blockSize := frontendBlockSize
volumeSize := frontendVolumeSize
if blockSize == 0 {
blockSize = nvme.DefaultBlockSize
}
if volumeSize == 0 {
volumeSize = nvme.DefaultVolumeBlocks * uint64(blockSize)
}
nvmeTarget = nvmerdma.NewTarget(nvmerdma.TargetConfig{
Listen: f.nvmeListen,
SubsysNQN: f.nvmeSubsysNQN,
VolumeID: f.volumeID,
NSID: uint32(f.nvmeNS),
BlockSize: frontendBlockSize,
VolumeSize: frontendVolumeSize,
ANA: newProjectionANAProvider(h.ProjectionView(), f.volumeID, f.replicaID, f.nvmeSubsysNQN),
},
})
BlockSize: blockSize,
VolumeSize: volumeSize,
Provider: provider,
})
} else {
var probeProvider nvme.ProbeBackendProvider
if durableProv != nil {
probeProvider = &durableProbeProvider{provider: durableProv}
}
nvmeTarget = nvme.NewTarget(nvme.TargetConfig{
Transport: nvme.TransportTCP,
Listen: f.nvmeListen,
SubsysNQN: f.nvmeSubsysNQN,
VolumeID: f.volumeID,
Provider: provider,
ProbeProvider: probeProvider,
ControllerID: nvmeControllerIDFromReplicaID(f.replicaID),
MaxH2CDataLength: uint32(f.nvmeMaxH2C),
Handler: nvme.HandlerConfig{
NSID: uint32(f.nvmeNS),
BlockSize: frontendBlockSize,
VolumeSize: frontendVolumeSize,
ANA: newProjectionANAProvider(h.ProjectionView(), f.volumeID, f.replicaID, f.nvmeSubsysNQN),
},
})
}
nvmeAddr, err := nvmeTarget.Start()
if err != nil {
fmt.Fprintln(os.Stderr, "blockvolume: nvme target:", err)
@@ -950,15 +973,17 @@ func run(f flags) int {
NvmeAddr: nvmeAddr,
SubsysNQN: f.nvmeSubsysNQN,
})
frontendTargets = append(frontendTargets, &control.FrontendTarget{
Protocol: "nvme",
Addr: nvmeAddr,
Nqn: f.nvmeSubsysNQN,
Nsid: uint32(f.nvmeNS),
})
h.SetFrontendTargets(frontendTargets)
if shouldPublishNVMeFrontendTarget(f.nvmeTransport) {
frontendTargets = append(frontendTargets, &control.FrontendTarget{
Protocol: "nvme",
Addr: nvmeAddr,
Nqn: f.nvmeSubsysNQN,
Nsid: uint32(f.nvmeNS),
})
h.SetFrontendTargets(frontendTargets)
}
if status != nil {
status.SetFrontendCapabilities(nvmeFrontendCapabilities(f.nvmeListen, true))
status.SetFrontendCapabilities(nvmeFrontendCapabilities(f.nvmeListen, f.nvmeTransport, true))
}
}
@@ -1002,13 +1027,23 @@ func run(f flags) int {
return 0
}
func nvmeFrontendCapabilities(nvmeListen string, listenerStarted bool) []volume.FrontendTransportCapability {
return nvmeFrontendCapabilitiesWithRDMAPreflight(nvmeListen, listenerStarted, nvmeRDMAPreflightFacts(nvmeListen))
func shouldPublishNVMeFrontendTarget(transport string) bool {
return transport == "tcp"
}
func nvmeFrontendCapabilitiesWithRDMAPreflight(nvmeListen string, listenerStarted bool, rdmaFacts []volume.FrontendTransportPreflightFact) []volume.FrontendTransportCapability {
tcpStarted := listenerStarted && nvmeListen != ""
rdmaStart := nvmeRDMAListenerStartDecision(false, rdmaFacts)
func nvmeFrontendCapabilities(nvmeListen, selectedTransport string, listenerStarted bool) []volume.FrontendTransportCapability {
return nvmeFrontendCapabilitiesWithRDMAPreflight(nvmeListen, selectedTransport, listenerStarted, nvmeRDMAPreflightFacts(nvmeListen))
}
func nvmeFrontendCapabilitiesWithRDMAPreflight(nvmeListen, selectedTransport string, listenerStarted bool, rdmaFacts []volume.FrontendTransportPreflightFact) []volume.FrontendTransportCapability {
tcpStarted := listenerStarted && nvmeListen != "" && selectedTransport == "tcp"
rdmaSelected := selectedTransport == "rdma"
rdmaStarted := listenerStarted && nvmeListen != "" && rdmaSelected && nvmerdma.Implemented()
rdmaStart := nvmeRDMAListenerStartDecision(rdmaSelected, rdmaFacts)
rdmaReason := "nvme_rdma_transport_unsupported"
if rdmaStarted {
rdmaReason = "implemented"
}
return []volume.FrontendTransportCapability{
{
Protocol: "nvme",
@@ -1023,12 +1058,12 @@ func nvmeFrontendCapabilitiesWithRDMAPreflight(nvmeListen string, listenerStarte
{
Protocol: "nvme",
Transport: "rdma",
Supported: false,
ListenerImplemented: false,
ListenerStarted: false,
Supported: rdmaStarted,
ListenerImplemented: nvmerdma.Implemented(),
ListenerStarted: rdmaStarted,
StartAllowed: rdmaStart.allowed,
StartReason: rdmaStart.reason,
Reason: "nvme_rdma_transport_unsupported",
Reason: rdmaReason,
Preflight: append([]volume.FrontendTransportPreflightFact(nil), rdmaFacts...),
},
}
@@ -1044,29 +1079,55 @@ func nvmeRDMAListenerStartDecision(enabled bool, facts []volume.FrontendTranspor
return nvmeRDMAListenerStart{allowed: false, reason: "nvme_rdma_listener_disabled"}
}
for _, fact := range facts {
// nvme-rdma is an initiator module. Keep it visible as a host fact, but
// do not require it on a target that serves through nvmet-rdma.
if fact.Name == "nvme_rdma_module" {
continue
}
if !fact.Available {
return nvmeRDMAListenerStart{allowed: false, reason: fact.Reason}
}
}
return nvmeRDMAListenerStart{allowed: false, reason: "nvme_rdma_transport_unsupported"}
if !nvmerdma.Implemented() {
return nvmeRDMAListenerStart{allowed: false, reason: "nvme_rdma_transport_unsupported"}
}
return nvmeRDMAListenerStart{allowed: true, reason: "implemented"}
}
func nvmeRDMAPreflightFacts(nvmeListen string) []volume.FrontendTransportPreflightFact {
return []volume.FrontendTransportPreflightFact{
nvmeRDMAModuleFact(),
kernelModuleFact("nvmet-rdma", "nvmet_rdma_module"),
kernelModuleFact("nbd", "nbd_module"),
rdmaDeviceFact(),
rdmaBindAddressFact(nvmeListen),
configFSFact(),
}
}
func nvmeRDMAModuleFact() volume.FrontendTransportPreflightFact {
if _, err := os.Stat("/sys/module/nvme_rdma"); err == nil {
return volume.FrontendTransportPreflightFact{Name: "nvme_rdma_module", Available: true, Reason: "nvme_rdma_module_loaded"}
return kernelModuleFact("nvme-rdma", "nvme_rdma_module")
}
func kernelModuleFact(module, factName string) volume.FrontendTransportPreflightFact {
sysName := strings.ReplaceAll(module, "-", "_")
if _, err := os.Stat("/sys/module/" + sysName); err == nil {
return volume.FrontendTransportPreflightFact{Name: factName, Available: true, Reason: factName + "_loaded"}
}
if data, err := os.ReadFile("/proc/modules"); err == nil && strings.Contains(string(data), "nvme_rdma ") {
return volume.FrontendTransportPreflightFact{Name: "nvme_rdma_module", Available: true, Reason: "nvme_rdma_module_loaded"}
if data, err := os.ReadFile("/proc/modules"); err == nil && strings.Contains(string(data), sysName+" ") {
return volume.FrontendTransportPreflightFact{Name: factName, Available: true, Reason: factName + "_loaded"}
}
return volume.FrontendTransportPreflightFact{Name: "nvme_rdma_module", Available: false, Reason: "nvme_rdma_module_missing"}
if err := exec.Command("modinfo", module).Run(); err == nil {
return volume.FrontendTransportPreflightFact{Name: factName, Available: true, Reason: factName + "_available"}
}
return volume.FrontendTransportPreflightFact{Name: factName, Available: false, Reason: factName + "_missing"}
}
func configFSFact() volume.FrontendTransportPreflightFact {
if _, err := os.Stat("/sys/kernel/config"); err == nil {
return volume.FrontendTransportPreflightFact{Name: "configfs", Available: true, Reason: "configfs_available"}
}
return volume.FrontendTransportPreflightFact{Name: "configfs", Available: false, Reason: "configfs_missing"}
}
func rdmaDeviceFact() volume.FrontendTransportPreflightFact {
@@ -0,0 +1,234 @@
//go:build linux
package nbd
import (
"context"
"errors"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
"syscall"
"time"
"golang.org/x/sys/unix"
)
const (
nbdSetSock = uintptr(0xab00)
nbdSetBlockSize = uintptr(0xab01)
nbdDoIt = uintptr(0xab03)
nbdClearSock = uintptr(0xab04)
nbdClearQueue = uintptr(0xab05)
nbdSetSizeBlocks = uintptr(0xab07)
nbdDisconnect = uintptr(0xab08)
nbdSetFlags = uintptr(0xab0a)
nbdFlagHasFlags = uintptr(1 << 0)
nbdFlagSendFlush = uintptr(1 << 2)
nbdFlagSendFUA = uintptr(1 << 3)
)
type Config struct {
Backend Backend
BlockSize uint32
Size uint64
Device string
}
type Device struct {
path string
fd int
serverFile *os.File
cancel context.CancelFunc
doItDone chan error
serveDone chan error
closeOnce sync.Once
closeErr error
}
func Start(cfg Config) (*Device, error) {
if cfg.Backend == nil {
return nil, errors.New("nbd: backend required")
}
if cfg.BlockSize == 0 || cfg.Size == 0 || cfg.Size%uint64(cfg.BlockSize) != 0 {
return nil, fmt.Errorf("nbd: invalid geometry blockSize=%d size=%d", cfg.BlockSize, cfg.Size)
}
if err := runModprobe("nbd", "max_part=0", "nbds_max=16"); err != nil {
return nil, err
}
path, fd, err := openDevice(cfg.Device)
if err != nil {
return nil, err
}
cleanupFD := true
defer func() {
if cleanupFD {
_ = unix.Close(fd)
}
}()
sockets, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_STREAM|unix.SOCK_CLOEXEC, 0)
if err != nil {
return nil, fmt.Errorf("nbd: socketpair: %w", err)
}
kernelFD, serverFD := sockets[0], sockets[1]
defer func() {
if kernelFD >= 0 {
_ = unix.Close(kernelFD)
}
if serverFD >= 0 {
_ = unix.Close(serverFD)
}
}()
if err := ioctlArg(fd, nbdSetBlockSize, uintptr(cfg.BlockSize)); err != nil {
return nil, fmt.Errorf("nbd: set block size: %w", err)
}
if err := ioctlArg(fd, nbdSetSizeBlocks, uintptr(cfg.Size/uint64(cfg.BlockSize))); err != nil {
return nil, fmt.Errorf("nbd: set size blocks: %w", err)
}
if err := ioctlArg(fd, nbdSetFlags, nbdFlagHasFlags|nbdFlagSendFlush|nbdFlagSendFUA); err != nil {
return nil, fmt.Errorf("nbd: set flags: %w", err)
}
if err := ioctlArg(fd, nbdSetSock, uintptr(kernelFD)); err != nil {
return nil, fmt.Errorf("nbd: set socket: %w", err)
}
_ = unix.Close(kernelFD)
kernelFD = -1
serverFile := os.NewFile(uintptr(serverFD), "sw-block-nbd")
serverFD = -1
ctx, cancel := context.WithCancel(context.Background())
d := &Device{
path: path,
fd: fd,
serverFile: serverFile,
cancel: cancel,
doItDone: make(chan error, 1),
serveDone: make(chan error, 1),
}
go func() {
d.serveDone <- protocolServer{backend: cfg.Backend, size: cfg.Size}.serve(ctx, serverFile)
}()
go func() {
d.doItDone <- ioctlArg(fd, nbdDoIt, 0)
}()
if err := waitActive(path, 2*time.Second); err != nil {
_ = d.Close()
return nil, err
}
cleanupFD = false
return d, nil
}
func (d *Device) Path() string {
if d == nil {
return ""
}
return d.path
}
func (d *Device) Close() error {
if d == nil {
return nil
}
d.closeOnce.Do(func() {
d.cancel()
_ = ioctlArg(d.fd, nbdDisconnect, 0)
_ = d.serverFile.Close()
d.waitDone(d.doItDone)
d.waitDone(d.serveDone)
_ = ioctlArg(d.fd, nbdClearQueue, 0)
_ = ioctlArg(d.fd, nbdClearSock, 0)
if err := unix.Close(d.fd); err != nil && d.closeErr == nil {
d.closeErr = err
}
})
return d.closeErr
}
func (d *Device) waitDone(ch <-chan error) {
select {
case err := <-ch:
if err != nil && !errors.Is(err, syscall.EINVAL) && !errors.Is(err, syscall.EPIPE) && !errors.Is(err, io.EOF) && d.closeErr == nil {
d.closeErr = err
}
case <-time.After(5 * time.Second):
if d.closeErr == nil {
d.closeErr = errors.New("nbd: timed out stopping device")
}
}
}
func runModprobe(module string, args ...string) error {
argv := append([]string{module}, args...)
out, err := exec.Command("modprobe", argv...).CombinedOutput()
if err != nil {
return fmt.Errorf("nbd: modprobe %s: %w: %s", module, err, strings.TrimSpace(string(out)))
}
return nil
}
func openDevice(requested string) (string, int, error) {
if requested != "" {
fd, err := unix.Open(requested, unix.O_RDWR|unix.O_EXCL|unix.O_CLOEXEC, 0)
if err != nil {
return "", -1, fmt.Errorf("nbd: open %s: %w", requested, err)
}
return requested, fd, nil
}
paths, err := filepath.Glob("/dev/nbd*")
if err != nil {
return "", -1, fmt.Errorf("nbd: list devices: %w", err)
}
sort.Slice(paths, func(i, j int) bool { return nbdNumber(paths[i]) < nbdNumber(paths[j]) })
for _, path := range paths {
fd, err := unix.Open(path, unix.O_RDWR|unix.O_EXCL|unix.O_CLOEXEC, 0)
if err == nil {
return path, fd, nil
}
if !errors.Is(err, syscall.EBUSY) {
return "", -1, fmt.Errorf("nbd: open %s: %w", path, err)
}
}
return "", -1, errors.New("nbd: no free /dev/nbd device")
}
func nbdNumber(path string) int {
n, err := strconv.Atoi(strings.TrimPrefix(filepath.Base(path), "nbd"))
if err != nil {
return int(^uint(0) >> 1)
}
return n
}
func waitActive(path string, timeout time.Duration) error {
pidPath := filepath.Join("/sys/block", filepath.Base(path), "pid")
deadline := time.Now().Add(timeout)
for time.Now().Before(deadline) {
data, err := os.ReadFile(pidPath)
if err == nil && strings.TrimSpace(string(data)) != "" {
return nil
}
time.Sleep(20 * time.Millisecond)
}
return fmt.Errorf("nbd: device %s did not become active", path)
}
func ioctlArg(fd int, request, arg uintptr) error {
_, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), request, arg)
if errno != 0 {
return errno
}
return nil
}
@@ -0,0 +1,22 @@
//go:build !linux
package nbd
import "errors"
type Config struct {
Backend Backend
BlockSize uint32
Size uint64
Device string
}
type Device struct{}
func Start(Config) (*Device, error) {
return nil, errors.New("nbd: Linux required")
}
func (d *Device) Path() string { return "" }
func (d *Device) Close() error { return nil }
+130
View File
@@ -0,0 +1,130 @@
package nbd
import (
"context"
"encoding/binary"
"errors"
"io"
"syscall"
)
const (
nbdRequestMagic = uint32(0x25609513)
nbdReplyMagic = uint32(0x67446698)
nbdCmdRead = uint32(0)
nbdCmdWrite = uint32(1)
nbdCmdDisc = uint32(2)
nbdCmdFlush = uint32(3)
nbdCmdMask = uint32(0xffff)
nbdCmdFUA = uint32(1 << 16)
)
// Backend is the minimum block contract required by the kernel NBD bridge.
type Backend interface {
Read(context.Context, int64, []byte) (int, error)
Write(context.Context, int64, []byte) (int, error)
Sync(context.Context) error
}
type protocolServer struct {
backend Backend
size uint64
}
func (s protocolServer) serve(ctx context.Context, rw io.ReadWriter) error {
header := make([]byte, 28)
for {
if _, err := io.ReadFull(rw, header); err != nil {
return err
}
if binary.BigEndian.Uint32(header[0:4]) != nbdRequestMagic {
return errors.New("nbd: invalid request magic")
}
command := binary.BigEndian.Uint32(header[4:8])
handle := header[8:16]
offset := binary.BigEndian.Uint64(header[16:24])
length := binary.BigEndian.Uint32(header[24:28])
if command&nbdCmdMask == nbdCmdDisc {
return nil
}
if offset > s.size || uint64(length) > s.size-offset {
if command&nbdCmdMask == nbdCmdWrite {
if _, err := io.CopyN(io.Discard, rw, int64(length)); err != nil {
return err
}
}
if err := writeReply(rw, handle, syscall.EINVAL, nil); err != nil {
return err
}
continue
}
switch command & nbdCmdMask {
case nbdCmdRead:
data := make([]byte, int(length))
n, err := s.backend.Read(ctx, int64(offset), data)
if err != nil || n != len(data) {
if err := writeReply(rw, handle, syscall.EIO, nil); err != nil {
return err
}
continue
}
if err := writeReply(rw, handle, 0, data); err != nil {
return err
}
case nbdCmdWrite:
data := make([]byte, int(length))
if _, err := io.ReadFull(rw, data); err != nil {
return err
}
n, err := s.backend.Write(ctx, int64(offset), data)
if err == nil && n == len(data) && command&nbdCmdFUA != 0 {
err = s.backend.Sync(ctx)
}
if err != nil || n != len(data) {
if err := writeReply(rw, handle, syscall.EIO, nil); err != nil {
return err
}
continue
}
if err := writeReply(rw, handle, 0, nil); err != nil {
return err
}
case nbdCmdFlush:
if err := s.backend.Sync(ctx); err != nil {
if err := writeReply(rw, handle, syscall.EIO, nil); err != nil {
return err
}
continue
}
if err := writeReply(rw, handle, 0, nil); err != nil {
return err
}
default:
if err := writeReply(rw, handle, syscall.EOPNOTSUPP, nil); err != nil {
return err
}
}
}
}
func writeReply(w io.Writer, handle []byte, errno syscall.Errno, data []byte) error {
header := make([]byte, 16)
binary.BigEndian.PutUint32(header[0:4], nbdReplyMagic)
binary.BigEndian.PutUint32(header[4:8], uint32(errno))
copy(header[8:16], handle)
if _, err := w.Write(header); err != nil {
return err
}
if len(data) == 0 {
return nil
}
_, err := w.Write(data)
return err
}
@@ -0,0 +1,161 @@
package nbd
import (
"bytes"
"context"
"encoding/binary"
"io"
"sync"
"testing"
)
type memoryBackend struct {
mu sync.Mutex
data []byte
syncs int
failIO bool
}
func (b *memoryBackend) Read(_ context.Context, offset int64, p []byte) (int, error) {
b.mu.Lock()
defer b.mu.Unlock()
if b.failIO {
return 0, io.ErrUnexpectedEOF
}
return copy(p, b.data[offset:int(offset)+len(p)]), nil
}
func (b *memoryBackend) Write(_ context.Context, offset int64, p []byte) (int, error) {
b.mu.Lock()
defer b.mu.Unlock()
if b.failIO {
return 0, io.ErrUnexpectedEOF
}
return copy(b.data[offset:int(offset)+len(p)], p), nil
}
func (b *memoryBackend) Sync(context.Context) error {
b.mu.Lock()
defer b.mu.Unlock()
b.syncs++
return nil
}
func TestProtocolServerWriteReadFlushAndDisconnect(t *testing.T) {
backend := &memoryBackend{data: make([]byte, 4096)}
serverSide, clientSide := io.Pipe()
replyRead, replyWrite := io.Pipe()
done := make(chan error, 1)
go func() {
done <- protocolServer{backend: backend, size: uint64(len(backend.data))}.serve(
context.Background(), struct {
io.Reader
io.Writer
}{Reader: serverSide, Writer: replyWrite},
)
}()
handle := [8]byte{1, 2, 3, 4, 5, 6, 7, 8}
payload := []byte("phase163-rdma")
writeRequest(t, clientSide, nbdCmdWrite|nbdCmdFUA, handle, 512, payload)
readReply(t, replyRead, handle, nil)
writeRequest(t, clientSide, nbdCmdRead, handle, 512, make([]byte, len(payload)))
readReply(t, replyRead, handle, payload)
writeRequest(t, clientSide, nbdCmdFlush, handle, 0, nil)
readReply(t, replyRead, handle, nil)
writeRequest(t, clientSide, nbdCmdDisc, handle, 0, nil)
if err := <-done; err != nil {
t.Fatalf("serve: %v", err)
}
if backend.syncs != 2 {
t.Fatalf("syncs=%d want 2 (FUA + flush)", backend.syncs)
}
}
func TestProtocolServerRejectsOutOfRangeWithoutBackendIO(t *testing.T) {
backend := &memoryBackend{data: make([]byte, 1024)}
request := new(bytes.Buffer)
handle := [8]byte{9}
writeRequest(t, request, nbdCmdRead, handle, 1000, make([]byte, 64))
writeRequest(t, request, nbdCmdDisc, handle, 0, nil)
reply := new(bytes.Buffer)
if err := (protocolServer{backend: backend, size: 1024}).serve(context.Background(), struct {
io.Reader
io.Writer
}{Reader: request, Writer: reply}); err != nil {
t.Fatalf("serve: %v", err)
}
header := reply.Next(16)
if got := binary.BigEndian.Uint32(header[4:8]); got == 0 {
t.Fatal("out-of-range request unexpectedly succeeded")
}
}
func TestProtocolServerConsumesRejectedWritePayload(t *testing.T) {
backend := &memoryBackend{data: make([]byte, 1024)}
request := new(bytes.Buffer)
handle := [8]byte{7}
writeRequest(t, request, nbdCmdWrite, handle, 1000, make([]byte, 64))
writeRequest(t, request, nbdCmdFlush, handle, 0, nil)
writeRequest(t, request, nbdCmdDisc, handle, 0, nil)
reply := new(bytes.Buffer)
if err := (protocolServer{backend: backend, size: 1024}).serve(context.Background(), struct {
io.Reader
io.Writer
}{Reader: request, Writer: reply}); err != nil {
t.Fatalf("serve: %v", err)
}
first := reply.Next(16)
if got := binary.BigEndian.Uint32(first[4:8]); got == 0 {
t.Fatal("out-of-range write unexpectedly succeeded")
}
second := reply.Next(16)
if got := binary.BigEndian.Uint32(second[4:8]); got != 0 {
t.Fatalf("flush after rejected write errno=%d; request stream lost alignment", got)
}
}
func writeRequest(t *testing.T, w io.Writer, command uint32, handle [8]byte, offset uint64, payload []byte) {
t.Helper()
header := make([]byte, 28)
binary.BigEndian.PutUint32(header[0:4], nbdRequestMagic)
binary.BigEndian.PutUint32(header[4:8], command)
copy(header[8:16], handle[:])
binary.BigEndian.PutUint64(header[16:24], offset)
binary.BigEndian.PutUint32(header[24:28], uint32(len(payload)))
if _, err := w.Write(header); err != nil {
t.Fatalf("write request header: %v", err)
}
if command&nbdCmdMask == nbdCmdWrite {
if _, err := w.Write(payload); err != nil {
t.Fatalf("write request payload: %v", err)
}
}
}
func readReply(t *testing.T, r io.Reader, handle [8]byte, data []byte) {
t.Helper()
header := make([]byte, 16)
if _, err := io.ReadFull(r, header); err != nil {
t.Fatalf("read reply: %v", err)
}
if got := binary.BigEndian.Uint32(header[0:4]); got != nbdReplyMagic {
t.Fatalf("reply magic=%#x", got)
}
if got := binary.BigEndian.Uint32(header[4:8]); got != 0 {
t.Fatalf("reply errno=%d", got)
}
if !bytes.Equal(header[8:16], handle[:]) {
t.Fatalf("reply handle=%x want %x", header[8:16], handle)
}
if len(data) > 0 {
got := make([]byte, len(data))
if _, err := io.ReadFull(r, got); err != nil {
t.Fatalf("read reply data: %v", err)
}
if !bytes.Equal(got, data) {
t.Fatalf("reply data=%q want %q", got, data)
}
}
}
@@ -0,0 +1,204 @@
//go:build linux
package nvmerdma
import (
"errors"
"fmt"
"net"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"github.com/seaweedfs/seaweed-block/core/frontend/nbd"
)
const defaultConfigFSRoot = "/sys/kernel/config/nvmet"
func Implemented() bool { return true }
type linuxTarget struct {
nbd *nbd.Device
configfs *configFSTarget
closeOnce sync.Once
closeErr error
}
func startPlatformTarget(cfg TargetConfig, backend nbd.Backend) (platformTarget, string, error) {
if os.Geteuid() != 0 {
return nil, "", errors.New("nvmerdma: kernel target requires root")
}
host, service, err := net.SplitHostPort(cfg.Listen)
if err != nil {
return nil, "", fmt.Errorf("nvmerdma: invalid listen address %q: %w", cfg.Listen, err)
}
ip := net.ParseIP(host)
if ip == nil || ip.IsUnspecified() || ip.IsLoopback() {
return nil, "", fmt.Errorf("nvmerdma: RDMA listen address must use a non-loopback IP: %q", host)
}
port, err := strconv.Atoi(service)
if err != nil || port < 1 || port > 65535 {
return nil, "", fmt.Errorf("nvmerdma: invalid service port %q", service)
}
if cfg.SubsysNQN == "" || filepath.Base(cfg.SubsysNQN) != cfg.SubsysNQN {
return nil, "", fmt.Errorf("nvmerdma: invalid subsystem NQN %q", cfg.SubsysNQN)
}
if cfg.NSID == 0 {
return nil, "", errors.New("nvmerdma: NSID must be non-zero")
}
if err := modprobe("nvmet-rdma"); err != nil {
return nil, "", err
}
if _, err := os.Stat(defaultConfigFSRoot); err != nil {
return nil, "", fmt.Errorf("nvmerdma: configfs target unavailable: %w", err)
}
device, err := nbd.Start(nbd.Config{
Backend: backend,
BlockSize: cfg.BlockSize,
Size: cfg.VolumeSize,
})
if err != nil {
return nil, "", fmt.Errorf("nvmerdma: start backend bridge: %w", err)
}
configTarget := &configFSTarget{
root: defaultConfigFSRoot,
nqn: cfg.SubsysNQN,
nsid: cfg.NSID,
portID: port,
address: host,
service: service,
devicePath: device.Path(),
}
if err := configTarget.Start(); err != nil {
_ = device.Close()
return nil, "", fmt.Errorf("nvmerdma: configure kernel target: %w", err)
}
return &linuxTarget{nbd: device, configfs: configTarget}, cfg.Listen, nil
}
func (t *linuxTarget) Close() error {
t.closeOnce.Do(func() {
if err := t.configfs.Close(); err != nil {
t.closeErr = err
}
if err := t.nbd.Close(); err != nil && t.closeErr == nil {
t.closeErr = err
}
})
return t.closeErr
}
func modprobe(module string) error {
out, err := exec.Command("modprobe", module).CombinedOutput()
if err != nil {
return fmt.Errorf("nvmerdma: modprobe %s: %w: %s", module, err, strings.TrimSpace(string(out)))
}
return nil
}
type configFSTarget struct {
root string
nqn string
nsid uint32
portID int
address string
service string
devicePath string
started bool
}
func (t *configFSTarget) Start() (err error) {
subsystem := filepath.Join(t.root, "subsystems", t.nqn)
namespace := filepath.Join(subsystem, "namespaces", strconv.FormatUint(uint64(t.nsid), 10))
port := filepath.Join(t.root, "ports", strconv.Itoa(t.portID))
link := filepath.Join(port, "subsystems", t.nqn)
if _, err := os.Stat(subsystem); err == nil {
return fmt.Errorf("subsystem already exists: %s", t.nqn)
} else if !errors.Is(err, os.ErrNotExist) {
return err
}
if _, err := os.Stat(port); err == nil {
return fmt.Errorf("port ID already exists: %d", t.portID)
} else if !errors.Is(err, os.ErrNotExist) {
return err
}
defer func() {
if err != nil {
_ = t.cleanup()
}
}()
if err = os.Mkdir(subsystem, 0o755); err != nil {
return err
}
if err = writeConfig(filepath.Join(subsystem, "attr_allow_any_host"), "1"); err != nil {
return err
}
if err = os.MkdirAll(namespace, 0o755); err != nil {
return err
}
if err = writeConfig(filepath.Join(namespace, "device_path"), t.devicePath); err != nil {
return err
}
if err = writeConfig(filepath.Join(namespace, "enable"), "1"); err != nil {
return err
}
if err = os.Mkdir(port, 0o755); err != nil {
return err
}
for _, attr := range []struct{ name, value string }{
{name: "addr_traddr", value: t.address},
{name: "addr_trtype", value: "rdma"},
{name: "addr_trsvcid", value: t.service},
{name: "addr_adrfam", value: "ipv4"},
} {
if err = writeConfig(filepath.Join(port, attr.name), attr.value); err != nil {
return err
}
}
if err = os.MkdirAll(filepath.Dir(link), 0o755); err != nil {
return err
}
if err = os.Symlink(subsystem, link); err != nil {
return err
}
t.started = true
return nil
}
func (t *configFSTarget) Close() error {
if !t.started {
return nil
}
t.started = false
return t.cleanup()
}
func (t *configFSTarget) cleanup() error {
subsystem := filepath.Join(t.root, "subsystems", t.nqn)
namespace := filepath.Join(subsystem, "namespaces", strconv.FormatUint(uint64(t.nsid), 10))
port := filepath.Join(t.root, "ports", strconv.Itoa(t.portID))
link := filepath.Join(port, "subsystems", t.nqn)
var errs []error
if err := os.Remove(link); err != nil && !errors.Is(err, os.ErrNotExist) {
errs = append(errs, err)
}
if err := writeConfig(filepath.Join(namespace, "enable"), "0"); err != nil && !errors.Is(err, os.ErrNotExist) {
errs = append(errs, err)
}
for _, path := range []string{namespace, port, subsystem} {
if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) {
errs = append(errs, err)
}
}
return errors.Join(errs...)
}
func writeConfig(path, value string) error {
return os.WriteFile(path, []byte(value), 0o644)
}
@@ -0,0 +1,15 @@
//go:build !linux
package nvmerdma
import (
"errors"
"github.com/seaweedfs/seaweed-block/core/frontend/nbd"
)
func Implemented() bool { return false }
func startPlatformTarget(TargetConfig, nbd.Backend) (platformTarget, string, error) {
return nil, "", errors.New("nvmerdma: Linux required")
}
@@ -0,0 +1,113 @@
package nvmerdma
import (
"context"
"errors"
"fmt"
"sync"
"github.com/seaweedfs/seaweed-block/core/frontend"
)
type TargetConfig struct {
Listen string
SubsysNQN string
VolumeID string
NSID uint32
BlockSize uint32
VolumeSize uint64
Provider frontend.Provider
}
type Target struct {
cfg TargetConfig
mu sync.Mutex
platform platformTarget
}
type platformTarget interface {
Close() error
}
func NewTarget(cfg TargetConfig) *Target {
if cfg.Provider == nil {
panic("nvmerdma: NewTarget: Provider required")
}
return &Target{cfg: cfg}
}
func (t *Target) Start() (string, error) {
t.mu.Lock()
defer t.mu.Unlock()
if t.platform != nil {
return "", errors.New("nvmerdma: target already started")
}
backend := &providerBackend{provider: t.cfg.Provider, volumeID: t.cfg.VolumeID}
platform, addr, err := startPlatformTarget(t.cfg, backend)
if err != nil {
return "", err
}
t.platform = platform
return addr, nil
}
func (t *Target) Close() error {
if t == nil {
return nil
}
t.mu.Lock()
platform := t.platform
t.platform = nil
t.mu.Unlock()
if platform == nil {
return nil
}
return platform.Close()
}
type providerBackend struct {
provider frontend.Provider
volumeID string
mu sync.Mutex
backend frontend.Backend
}
func (b *providerBackend) get(ctx context.Context) (frontend.Backend, error) {
b.mu.Lock()
defer b.mu.Unlock()
if b.backend != nil {
return b.backend, nil
}
backend, err := b.provider.Open(ctx, b.volumeID)
if err != nil {
return nil, fmt.Errorf("nvmerdma: open backend: %w", err)
}
b.backend = backend
return backend, nil
}
func (b *providerBackend) Read(ctx context.Context, offset int64, p []byte) (int, error) {
backend, err := b.get(ctx)
if err != nil {
return 0, err
}
return backend.Read(ctx, offset, p)
}
func (b *providerBackend) Write(ctx context.Context, offset int64, p []byte) (int, error) {
backend, err := b.get(ctx)
if err != nil {
return 0, err
}
return backend.Write(ctx, offset, p)
}
func (b *providerBackend) Sync(ctx context.Context) error {
backend, err := b.get(ctx)
if err != nil {
return err
}
return backend.Sync(ctx)
}
@@ -1,136 +1,146 @@
# NVMe/RDMA Capability Boundary
Status: **non-claim**. Seaweed Block's implemented product path is still
NVMe/TCP for the supported lab. NVMe/RDMA and RoCE remain future work until a
real product transport and live I/O gates pass.
Status: **source-gated standalone supported-lab path**. Seaweed Block can serve
one explicitly configured Linux NVMe/RDMA target in the supported RoCE lab.
Kubernetes CSI publication/attach, multipath/failover, broad compatibility,
performance improvement, and production SLOs remain non-claims.
## Current Implemented Path
## Claim Matrix
The current Block NVMe path is:
| Capability | Current status |
| --- | --- |
| NVMe/TCP Kubernetes CSI path | Source-gated supported lab |
| NVMe/RDMA standalone Linux target | Source-gated supported lab, Phase 163 |
| NVMe/RDMA Kubernetes CSI publish/attach | Not implemented |
| NVMe/RDMA multipath or failover | Not implemented |
| Broad kernel, NIC, distro, or initiator compatibility | Not claimed |
| RDMA acceleration or performance SLO | Not claimed |
## Implemented Standalone Path
```text
Kubernetes PVC
-> CSI publish context
-> blockvolume NVMe/TCP frontend
-> Linux nvme connect -t tcp
-> mounted app pod write/read
Linux nvme-rdma initiator on m01
-> RoCE data-plane address 10.0.0.3 on m02
-> Linux kernel nvmet-rdma target
-> configfs namespace backed by /dev/nbdX
-> Seaweed Block NBD request bridge
-> frontend.Backend Read/Write/Sync
-> durable volume implementation
```
This is documented in the NVMe/TCP supported-lab evidence. It does not imply
RDMA.
The kernel owns NVMe-oF/RDMA protocol handling, queue pairs, memory
registration, and namespace presentation. Seaweed Block owns NBD request
translation and the target lifecycle that creates and removes NBD/configfs
state. This avoids the incorrect design of sending NVMe/TCP PDUs over an RDMA
socket and avoids implementing an NVMe/RDMA target protocol stack in Go.
## Host Capability Inputs
The bridge maps:
Host facts are necessary but not sufficient for a product claim:
- NBD read to `frontend.Backend.Read`;
- NBD write to `frontend.Backend.Write`;
- NBD flush and FUA completion to `frontend.Backend.Sync`;
- disconnect to bounded bridge shutdown.
- `nvme` CLI is present and can read subsystem state.
- `nvme-fabrics` and `nvme-tcp` are loaded or available for the current TCP
product path.
- `nvme-rdma` loaded or available makes a host a candidate, not a claim.
- `/sys/class/infiniband` device count and device names identify possible RDMA
hardware.
- RoCE IP/GID/device configuration must be captured as evidence before any
RDMA live I/O gate.
## Activation And Prerequisites
These facts can only say "this host might be able to run RDMA." They do not say
Seaweed Block can serve an NVMe/RDMA volume.
The path is explicit:
## Volume-Server Capability Inputs
```text
blockvolume \
--nvme-listen <roce-ip>:<port> \
--nvme-transport rdma \
--allow-external-nvme-bind \
--nvme-subsysnqn <nqn> \
--nvme-ns <nsid>
```
A future Block NVMe/RDMA claim needs product-owned volume-server facts, not only
host facts:
The current implementation is Linux-only and requires:
- supported frontend transports: `tcp` versus `rdma`;
- RDMA listener state: listening/not listening, bind IP, port, device, and GID;
- advertised NQN/NSID for the RDMA listener;
- status endpoint evidence that the volume server selected RDMA intentionally;
- clear fallback/refusal when RDMA is requested but unsupported.
- root privileges for NBD ioctls and configfs;
- `nbd` and `nvmet-rdma` kernel modules available;
- `/sys/kernel/config/nvmet` mounted and writable;
- an RDMA device and a non-loopback IP assigned to its data-plane netdev;
- the standard Linux `nvme-rdma` initiator on the client;
- a unique NQN, namespace ID, and target port.
Today the product boundary is still typed refusal: TCP is implemented and RDMA
is not.
Phase 158 adds the first read-only product-owned capability probe at:
The frontend capability endpoint reports RDMA as supported and started only
after the target has started:
```text
GET /status/frontend-capabilities?volume=<id>
```
The current response is intentionally conservative: TCP supported and RDMA unsupported,
with `reason=nvme_rdma_transport_unsupported` and no RDMA listener started. This
is a status/capability surface, not an RDMA data path.
The same endpoint carries module, RDMA-device, bind-address, implementation,
start-allowed, and listener-started facts. Missing prerequisites must fail
closed rather than create a false supported/listening state.
Phase 159 adds the standalone listener design gate. The main conclusion is that
RDMA must not be implemented as a fake `net.Listener` around the existing
NVMe/TCP PDU stream. The current `ListenerFactory` is a transport-selection
seam, but real RDMA needs a transport adapter or dedicated session path that
reuses command handlers without reusing TCP wire framing. The next implementation
slice is `phase160_nvme_rdma_transport_adapter_seam`.
## Phase 163 Live Evidence
Phase 160 adds that first adapter seam in code: `Session` now reads and writes
through a `sessionTransport` interface, with the current TCP path implemented by
`tcpPDUTransport` wrapping the existing NVMe/TCP `Reader`/`Writer`. RDMA remains
unsupported and `/status/frontend-capabilities` still reports
`nvme_rdma_transport_unsupported`.
Phase 161 extends the same capability surface with read-only RDMA preflight
facts: `nvme_rdma_module`, `rdma_device`, and `rdma_bind_address`. These facts
explain why RDMA cannot start on the current host while preserving
`supported=false`, `listenerStarted=false`, and the stable
`nvme_rdma_transport_unsupported` reason.
Phase 162 adds the disabled-by-default listener start decision skeleton. The
capability surface now carries `startAllowed=false` and a stable `startReason`
for RDMA: default-disabled first, preflight failures when explicitly evaluated,
and still `nvme_rdma_transport_unsupported` after preflight passes because no
listener implementation exists yet.
## Product Gap
The missing product work is a real NVMe-oF/RDMA target path:
- no RDMA listener implementation in `blockvolume`;
- no product-owned RDMA queue pair / memory registration path for NVMe-oF;
- no successful `nvme connect -t rdma` against a Seaweed Block target;
- no CSI publish context for RDMA frontend addresses;
- no Kubernetes NodeStage/NodeUnstage RDMA attach cleanup gate;
- no status/report/dashboard/explain surface for RDMA target health;
- no same-shape TCP versus RDMA performance evidence.
External RDMA work under `C:\work\rdma\seaweed-mono-rdma-refresh` is useful
evidence for VFS/object/RustVolume acceleration and library feasibility, but it
is not a Seaweed Block NVMe-oF/RDMA target and must not be described as one.
## Required Product Gates Before Claim
The minimum gates before any NVMe/RDMA claim are:
1. Standalone live I/O gate:
`blockvolume --nvme-transport rdma` starts a real RDMA listener,
Linux `nvme connect -t rdma` succeeds, write/read verifies, and cleanup
leaves no NVMe/RDMA residue.
2. Kubernetes publish/attach gate:
dynamic PVC publishes RDMA frontend context, CSI NodeStage connects through
`nvme connect -t rdma`, app pod writes/reads, delete/uninstall cleanup is
clean.
3. Status surface gate:
CRD/report/dashboard/explain show transport=`rdma`, endpoint/device evidence,
and failure reasons without false `Ready=True`.
4. Fallback/refusal gate:
unsupported or misconfigured RDMA must fail closed with a stable reason and
leave TCP behavior unchanged.
5. Performance gate:
only after correctness gates pass, compare same-shape TCP and RDMA runs with
product-owned counters. Until then, no acceleration or SLO claim.
## Phase 157 Decision
Phase 157 keeps the current public boundary:
TestOps run `20260718-010533-1ab1` passed 16/16 actions:
```text
NVMe/TCP: source-gated supported-lab product path.
NVMe/RDMA/RoCE: host capability and external-library evidence only; product non-claim.
rdma_implementation_path=kernel_nvmet_rdma_nbd_bridge
rdma_bind_ip=10.0.0.3
rdma_device=rocep1s0
rdma_netdev=enp1s0np0
linux_nvme_connect_rdma_succeeded=true
standalone_write_read_verified=true
flush_verified=true
seaweed_backend_write_observed=true
capability_endpoint_reports_rdma_supported=true
rdma_listener_started=true
rdma_not_published_to_csi=true
disconnect_cleanup_status=ok
cleanup_status=ok
phase163_decision=standalone_nvme_rdma_live_io_supported
```
The next useful product step is a standalone listener implementation spike that
can be tested only by the standalone live I/O gate; Kubernetes publish/attach
and performance claims remain out of scope.
The initiator wrote 4 KiB, issued `nvme flush`, read the namespace back, and
verified the checksum. Independently, the blockvolume log recorded
`durable: write observer dispatch lba=0 lsn=<value>` after persistence, proving
the request reached the Seaweed backend rather than stopping at a kernel-only
control target.
## Why This Is Not Yet A Kubernetes Claim
The standalone target is deliberately not advertised to blockmaster or CSI.
The existing publish-target path remains NVMe/TCP-only. Therefore Phase 163
does not prove:
- RDMA addresses in CSI publish context;
- CSI NodeStage/NodeUnstage using `nvme connect -t rdma`;
- mounted application I/O through a dynamic PVC;
- reconnect after target or node movement;
- RDMA multipath, ANA, or failover behavior;
- CRD/report/dashboard/explain agreement for RDMA target health;
- Kubernetes delete/uninstall cleanup of RDMA host state.
Silently advertising the standalone endpoint as a Kubernetes target before
those ownership and cleanup paths exist would create an unsafe partial claim.
## Next Gates
### Phase 164: Standalone Productization And Hardening
One coherent gate covers startup rollback, flush/FUA correctness, durable
restart/reconnect, multi-target isolation, bounded connect churn, negative
preflight/refusal, capability honesty, TCP regression, and zero residue.
### Phase 165: Kubernetes Publish/Attach
Only after Phase 164 passes should the product publish RDMA frontend context,
connect from CSI-node, mount an application PVC, expose status, and prove
delete/uninstall cleanup.
### Later: Multipath, Failover, And Performance
RDMA multipath/failover requires its own authority, ANA, reconnect, and mounted
I/O gates. Performance comparison must use the same backend, durability,
request shape, and host topology for TCP and RDMA. Until then, the NBD bridge
must not be described as an acceleration path or used for an SLO claim.
## Related External RDMA Work
`C:\work\rdma\seaweed-mono-rdma-refresh` and `C:\work\rdma\sra-next` provide
useful VFS/object/RustVolume/RDMA/NIXL evidence. They do not implement the
standard Linux NVMe/RDMA target used here and remain separate product surfaces.
@@ -104,6 +104,7 @@ The supported-lab claim is intentionally narrow:
| 160 | NVMe/RDMA transport adapter seam isolates TCP PDU wire path | PASS |
| 161 | NVMe/RDMA standalone preflight/refusal facts surface module/device/bind evidence | PASS |
| 162 | NVMe/RDMA listener start decision skeleton stays disabled by default | PASS |
| 163 | Standalone NVMe/RDMA live I/O through the Seaweed backend | PASS |
Key QA sign-offs:
@@ -811,8 +812,9 @@ image-pair smoke passes.
This evidence does not claim:
- RoCE or NVMe/RDMA data path. The current target is NVMe/TCP only, and
`--nvme-transport=rdma` is a refusal path.
- Kubernetes RoCE or NVMe/RDMA publish/attach. Phase 163 proves only an
explicit, source-gated standalone Linux path; it is not yet part of CSI
publish context, NodeStage/NodeUnstage, multipath, or failover.
- Performance, throughput, latency, or production SLO.
- Broad Linux distro, kernel, initiator, or cloud compatibility.
- Production HA, node-loss survival, or arbitrary unbounded path churn.
+5
View File
@@ -155,6 +155,11 @@ Seaweed Block can already demonstrate a narrow Kubernetes block-storage loop:
- Phase 162 adds a disabled-by-default RDMA listener start decision skeleton:
the product can report why start is not allowed, but still does not start an
RDMA listener or claim live I/O.
- Phase 163 implements and live-gates the first source-gated standalone
NVMe/RDMA path. Linux `nvme connect -t rdma` reaches the real Seaweed backend
through kernel `nvmet-rdma` plus a product-owned NBD bridge; write/read/flush
and cleanup pass on the 10.0.0.x RoCE lab network. Kubernetes publication,
failover, broad compatibility, and performance remain non-claims.
- Kubernetes NVMe/TCP mounted reconnect is source-gated through changed
desired path-set evidence: CSI-node can connect a newly published desired
NVMe path, prune the stale old host path for the same NQN, preserve pod
+1 -1
View File
@@ -5,6 +5,7 @@ go 1.25
require (
github.com/container-storage-interface/spec v1.12.0
github.com/golang/protobuf v1.5.4
golang.org/x/sys v0.40.0
google.golang.org/grpc v1.80.0
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v3 v3.0.1
@@ -12,7 +13,6 @@ require (
require (
golang.org/x/net v0.49.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 // indirect
)
+71 -45
View File
@@ -1,64 +1,90 @@
# Current Plan: Phase 163 NVMe/RDMA Standalone Listener Implementation Spike
# Current Plan: Phase 164 NVMe/RDMA Standalone Productization And Hardening
Status: planning.
Phase 162 closed the disabled-by-default listener skeleton:
Phase 163 proved the first real Seaweed Block NVMe/RDMA data path:
```text
phase162_nvme_rdma_standalone_listener_skeleton_gate_status=ok
rdma_listener_start_path_defined=true
rdma_listener_disabled_by_default=true
preflight_failure_maps_to_stable_reasons=true
capability_endpoint_reports_listener_started_false=true
tcp_behavior_unchanged=true
linux_nvme_connect_live_io_not_claimed=true
k8s_publish_attach_claim_allowed=false
performance_slo_claim_allowed=false
phase162_decision=rdma_start_decision_skeleton_disabled_by_default
next_recommendation=phase163_nvme_rdma_standalone_listener_impl_spike
Linux nvme-rdma initiator
-> kernel nvmet-rdma target
-> product-owned NBD bridge
-> Seaweed Block frontend.Backend
```
The supported-lab gate connected from m01 to the m02 RoCE address, verified
write/read/flush against the Seaweed backend, and left no target, host, or NBD
residue. Kubernetes publication, failover, and performance remain non-claims.
## Goal
Attempt the smallest standalone NVMe/RDMA listener implementation spike. The
only acceptable success proof is a standalone live I/O gate using Linux
`nvme connect -t rdma` against a Seaweed Block target. Kubernetes publish/attach
and performance claims stay deferred.
Turn the Phase 163 implementation spike into one hardened standalone product
slice before any Kubernetes integration. This phase owns correctness, restart,
isolation, refusal, observability, and cleanup as one close gate rather than as
separate small phases.
## Deliverables
### D1. Lifecycle And Rollback
- Allocate and release NBD devices without cross-run contamination.
- Roll back NBD/configfs state after partial startup failure.
- Handle normal termination and repeated start/stop cleanly.
- Avoid fixed test ports and stale NQNs in the formal gate.
### D2. Data And Flush Correctness
- Verify aligned 4 KiB and larger sequential write/read checksums.
- Verify NVMe flush and FUA reach the Seaweed backend sync boundary.
- Reject out-of-range or malformed requests without desynchronizing the bridge.
### D3. Durable Restart And Reconnect
- Write known data through `nvme connect -t rdma`.
- Disconnect and restart `blockvolume` with the same durable root.
- Reconnect and verify the pre-restart checksum.
- Keep capability status honest while the listener is down or restarting.
### D4. Isolation And Bounded Churn
- Run two standalone targets with distinct NQN, port, namespace, and NBD device.
- Prove writes do not cross volume boundaries.
- Run repeated connect/write/read/disconnect cycles and finish with zero residue.
### D5. Refusal And Regression Boundary
- Fail closed for missing modules, configfs, RDMA device, bind address, port
conflict, or insufficient privilege with stable evidence.
- Keep the existing NVMe/TCP path and tests unchanged.
- Keep RDMA absent from master/CSI publish context in this phase.
- Make no throughput, latency, acceleration, HA, or production SLO claim.
### D6. Close Gate
- Package D1-D5 as one TestOps scenario with independent host, target, backend,
and cleanup evidence.
- Update the source-gated supported-lab boundary from the same run bundle.
## Required Evidence
```text
phase163_nvme_rdma_standalone_listener_impl_spike_status=<ok|blocked_with_reason>
rdma_listener_impl_attempted=true
rdma_bind_ip=<100Gb/RoCE/data-plane IP or blocked>
rdma_device=<device or blocked>
linux_nvme_connect_rdma_succeeded=<true|false>
standalone_write_read_verified=<true|false>
disconnect_cleanup_status=<ok|not_reached>
capability_endpoint_reports_rdma_supported=<true|false>
phase164_nvme_rdma_standalone_hardening_status=ok
startup_rollback_verified=true
small_and_large_io_verified=true
flush_and_fua_verified=true
durable_restart_reconnect_verified=true
multi_target_isolation_verified=true
bounded_connect_churn_verified=true
negative_preflight_refusal_verified=true
tcp_behavior_unchanged=true
k8s_publish_attach_claim_allowed=false
rdma_not_published_to_csi=true
performance_slo_claim_allowed=false
next_recommendation=<specific next phase>
cleanup_status=ok
next_recommendation=phase165_nvme_rdma_kubernetes_publish_attach
```
## Boundaries
- Do not wire Kubernetes publish/attach in this phase.
- Do not claim performance or acceleration.
- If live RDMA I/O cannot pass, keep `supported=false` and report the blocking
reason instead of partial success.
- Preserve TCP behavior and existing refusal tests.
## Candidate Work
1. Select the minimal RDMA implementation library/path.
2. Bind only to the RDMA/data-plane address, not the management LAN.
3. Feed real RDMA commands into the existing transport adapter seam.
4. Use Linux `nvme connect -t rdma` for live proof.
5. Verify write/read and cleanup, or close as blocked with precise evidence.
## Exit Criteria
Phase 163 can close only when the standalone gate either passes real RDMA live
I/O or records a concrete blocker that keeps the product in unsupported state.
Phase 164 closes only when the complete standalone hardening gate passes from
one TestOps bundle. Phase 165 may then own Kubernetes publish context,
NodeStage/NodeUnstage, mounted workload I/O, status agreement, and delete
cleanup. Performance comparison comes only after those correctness gates.
@@ -0,0 +1,70 @@
# Phase 163 Finished Plan: NVMe/RDMA Standalone Listener Implementation
Status: **closed 2026-07-18, live TestOps gate PASS**.
## Problem
Phases 157-162 had capability facts, a transport seam, preflight, and a
disabled start decision, but no Seaweed Block target accepted a standard Linux
`nvme connect -t rdma`. Host RDMA capability alone could not establish a
product data-path claim.
## Design Decision
The implementation uses the standard Linux NVMe/RDMA protocol stack rather
than reproducing NVMe-oF/RDMA queue-pair semantics in Go:
```text
Linux nvme-rdma initiator
-> kernel nvmet-rdma target and namespace
-> /dev/nbdX
-> product-owned NBD request bridge
-> Seaweed Block frontend.Backend
```
The kernel owns NVMe/RDMA protocol compliance. The NBD bridge owns translation
of read, write, flush, FUA, and disconnect into the existing Seaweed backend.
The path is Linux-only and requires root, configfs, `nvmet-rdma`, `nbd`, an
RDMA device, and a non-loopback data-plane address.
## Work
- Added a bounded NBD protocol bridge and Linux NBD device lifecycle.
- Added a Linux NVMe/RDMA target lifecycle over configfs and `nvmet-rdma`.
- Wired explicit `--nvme-transport=rdma` startup into `blockvolume`.
- Kept RDMA targets out of master/CSI publication.
- Made frontend capability status report the actually started RDMA listener.
- Added unit coverage for protocol mapping, bounds, and stream alignment.
- Added a live TestOps gate using the m02 `10.0.0.3` RoCE address and a standard
m01 Linux NVMe/RDMA initiator.
## Evidence
Run: `20260718-010533-1ab1`, 16/16 actions PASS.
```text
phase163_nvme_rdma_standalone_listener_impl_spike_status=ok
rdma_implementation_path=kernel_nvmet_rdma_nbd_bridge
rdma_bind_ip=10.0.0.3
rdma_device=rocep1s0
rdma_netdev=enp1s0np0
linux_nvme_connect_rdma_succeeded=true
standalone_write_read_verified=true
flush_verified=true
seaweed_backend_write_observed=true
capability_endpoint_reports_rdma_supported=true
rdma_listener_started=true
rdma_not_published_to_csi=true
performance_slo_claim_allowed=false
disconnect_cleanup_status=ok
cleanup_status=ok
phase163_decision=standalone_nvme_rdma_live_io_supported
next_recommendation=phase164_nvme_rdma_standalone_hardening
```
## Conclusion
Seaweed Block now has a real, source-gated standalone NVMe/RDMA data path in
the supported Linux lab. This is not yet a Kubernetes publish/attach,
multi-path/failover, broad compatibility, performance, or production claim.
Phase 164 hardens the standalone lifecycle before Kubernetes integration.
+20 -7
View File
@@ -109,6 +109,15 @@ This is the short internal roadmap. Keep it current and readable.
- Phase 162 adds a disabled-by-default listener start decision skeleton. It
reports start refusal reasons but still does not start an RDMA listener or
claim live I/O.
- Phase 163 closes the first real standalone NVMe/RDMA data path. A standard
Linux initiator connected over the 10.0.0.x RoCE network, wrote, flushed,
and read back data through kernel `nvmet-rdma`, the product-owned NBD bridge,
and the Seaweed backend. This source-gated claim excludes Kubernetes
publication, failover, broad compatibility, and performance/SLOs.
- Phase 164 is the next coherent gate: productize and harden the standalone
path across rollback, flush/FUA, durable restart/reconnect, multi-target
isolation, bounded churn, refusal evidence, and zero-residue cleanup before
Phase 165 owns Kubernetes RDMA publish/attach.
Do not skip from scripts directly to mutating operator lifecycle. Helm has
stabilized the installation contract, and Phase 35 added read-only CRD status,
@@ -544,17 +553,21 @@ rebuild, delete safety, or cleanup must start as a separate gated phase.
diagnostic boundary mismatch: superblock WAL byte-position metadata was being
reported as the LSN `HeadLSN` after recovery. Storage and durable-provider
regressions now assert recovered `HeadLSN` is bounded by the recovered LSN.
- Later protocol candidates: complete a real NVMe/RDMA target, characterize
NVMe/TCP performance, or bridge to object/NIXL acceleration where the product
surface is object/storage rather than block PVC. Keep these separate so
correctness, transport, and performance claims do not get mixed.
- The standalone NVMe/RDMA implementation now exists behind a source-gated
Linux supported-lab boundary. Next, harden its lifecycle and then add a
separate Kubernetes publish/attach gate. Keep transport correctness,
Kubernetes lifecycle, performance characterization, and object/NIXL
acceleration as separate claims.
### Track E: Protocol / Backend Expansion
- Current: iSCSI and NVMe-oF are protocol-gated frontends. `walstore` remains
the MVP backend.
- Next: storage-engine boundary tests, backend pressure behavior, and
smartwal/delta experiments behind explicit gates.
the MVP backend. NVMe/TCP has a Kubernetes supported-lab path; NVMe/RDMA has
a narrower standalone Linux supported-lab path through kernel `nvmet-rdma`
and a product-owned NBD-to-backend bridge.
- Next: Phase 164 standalone NVMe/RDMA hardening, then Phase 165 Kubernetes
publish/attach. Storage-engine boundary and smartwal/delta experiments remain
explicit, separate gates.
- Protocol hardening now has a dedicated working area under
`internal/docs/protocol/`. New protocol semantics should update the control
model, invariant ledger, and anti-pattern checklist there before release
@@ -0,0 +1,60 @@
# Phase 163 QA Sign-Off: NVMe/RDMA Standalone Live I/O
Status: **PASS** on 2026-07-18.
TestOps run: `20260718-010533-1ab1`.
Local bundle: `results/20260718-010533-1ab1`.
## Verdict
The supported lab completed a standard Linux `nvme connect -t rdma` from m01
to a Seaweed Block target on m02. A 4 KiB write, NVMe flush, and checksum
readback passed. The blockvolume log independently confirmed a durable write
observer dispatch with a real LSN after the backend write; the test did not
stop at kernel target or raw block-device evidence.
## Gates
- Unit tests for NBD, NVMe/RDMA, NVMe/TCP, and blockvolume: PASS.
- m02 RDMA target bind on `10.0.0.3:11631`: PASS.
- m01 standard Linux NVMe/RDMA connect: PASS.
- Seaweed backend write/read/flush: PASS.
- Frontend capability reports implemented, supported, and started: PASS.
- RDMA remains absent from master/CSI publication: PASS.
- Existing TCP behavior checks: PASS.
- Host controller, configfs target, NBD device, and process cleanup: PASS.
The broader iSCSI process test
`TestT2Process_ISCSI_ReopenAfterMove_ServesNewLineage` remains red because its
projection does not return to Healthy within 30 seconds. The same test fails at
the unchanged `main` commit `be1ef07`; Phase 163 does not touch the iSCSI path.
## Evidence
```text
phase163_nvme_rdma_standalone_listener_impl_spike_status=ok
rdma_implementation_path=kernel_nvmet_rdma_nbd_bridge
rdma_bind_ip=10.0.0.3
rdma_device=rocep1s0
rdma_netdev=enp1s0np0
go_test_nbd_nvmerdma_nvme_blockvolume=ok
tcp_behavior_unchanged=true
rdma_not_published_to_csi=true
capability_endpoint_reports_rdma_supported=true
rdma_listener_started=true
backend_bridge_device=/dev/nbd0
linux_nvme_connect_rdma_succeeded=true
standalone_write_read_verified=true
flush_verified=true
seaweed_backend_write_observed=true
disconnect_cleanup_status=ok
cleanup_status=ok
phase163_decision=standalone_nvme_rdma_live_io_supported
```
## Boundary
This sign-off supports only the source-gated standalone Linux lab path. It does
not validate Kubernetes CSI publication/attach, multiple RDMA paths, failover,
performance improvement, broad hardware/kernel compatibility, or an SLO.
@@ -0,0 +1,232 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="${1:-$(pwd)}"
RUN_ID="${SW_BLOCK_PHASE163_RUN_ID:-$(date -u +%Y%m%dT%H%M%SZ)}"
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${ROOT}/results/phase163-nvme-rdma-standalone-live-gate}"
SUMMARY="${ARTIFACT_DIR}/phase163-nvme-rdma-standalone-live-summary.txt"
WORK="/tmp/sw-block-phase163-${RUN_ID}"
BIN="${WORK}/bin"
NQN="${SW_BLOCK_PHASE163_NQN:-nqn.2026-07.io.seaweedfs:phase163-${RUN_ID}}"
TARGET_IP="${SW_BLOCK_PHASE163_TARGET_IP:-10.0.0.3}"
TARGET_PORT="${SW_BLOCK_PHASE163_TARGET_PORT:-11631}"
RDMA_DEVICE="${SW_BLOCK_PHASE163_RDMA_DEVICE:-rocep1s0}"
RDMA_NETDEV="${SW_BLOCK_PHASE163_RDMA_NETDEV:-enp1s0np0}"
HOST_SSH_ADDR="${SW_BLOCK_PHASE163_HOST_SSH_ADDR:-192.168.1.181}"
HOST_SSH_USER="${SW_BLOCK_PHASE163_HOST_SSH_USER:-testdev}"
HOST_SSH_KEY="${SW_BLOCK_PHASE163_HOST_SSH_KEY:-/opt/work/testdev_key}"
MASTER_PID=""
VOLUME_PID=""
NBD_PATH=""
mkdir -p "${ARTIFACT_DIR}" "${BIN}"
: >"${SUMMARY}"
write_summary() {
echo "$*" | tee -a "${SUMMARY}" >/dev/null
}
cleanup() {
set +e
ssh -i "${HOST_SSH_KEY}" -o BatchMode=yes -o ConnectTimeout=5 \
"${HOST_SSH_USER}@${HOST_SSH_ADDR}" \
"sudo nvme disconnect -n '${NQN}' >/dev/null 2>&1 || true" >/dev/null 2>&1 || true
if [[ -n "${VOLUME_PID}" ]]; then
sudo kill -TERM "${VOLUME_PID}" >/dev/null 2>&1 || true
fi
if [[ -n "${MASTER_PID}" ]]; then
kill -TERM "${MASTER_PID}" >/dev/null 2>&1 || true
fi
for _ in $(seq 1 50); do
volume_alive=false
master_alive=false
[[ -n "${VOLUME_PID}" ]] && sudo kill -0 "${VOLUME_PID}" >/dev/null 2>&1 && volume_alive=true
[[ -n "${MASTER_PID}" ]] && kill -0 "${MASTER_PID}" >/dev/null 2>&1 && master_alive=true
[[ "${volume_alive}" == false && "${master_alive}" == false ]] && break
sleep 0.1
done
[[ -n "${VOLUME_PID}" ]] && sudo kill -KILL "${VOLUME_PID}" >/dev/null 2>&1 || true
[[ -n "${MASTER_PID}" ]] && kill -KILL "${MASTER_PID}" >/dev/null 2>&1 || true
case "${WORK}" in
/tmp/sw-block-phase163-*) sudo rm -rf -- "${WORK}" ;;
*) echo "refusing unsafe Phase 163 work cleanup: ${WORK}" >&2 ;;
esac
}
trap cleanup EXIT
write_summary "phase163_nvme_rdma_standalone_listener_impl_spike_status=running"
write_summary "rdma_listener_impl_attempted=true"
write_summary "rdma_implementation_path=kernel_nvmet_rdma_nbd_bridge"
write_summary "rdma_bind_ip=${TARGET_IP}"
write_summary "rdma_device=${RDMA_DEVICE}"
write_summary "rdma_netdev=${RDMA_NETDEV}"
write_summary "k8s_publish_attach_claim_allowed=false"
write_summary "performance_slo_claim_allowed=false"
[[ -d "/sys/class/infiniband/${RDMA_DEVICE}" ]]
[[ -d "/sys/class/infiniband/${RDMA_DEVICE}/device/net/${RDMA_NETDEV}" ]]
ip -4 -o addr show dev "${RDMA_NETDEV}" | grep -q " ${TARGET_IP}/"
ip route get "${TARGET_IP}" >"${ARTIFACT_DIR}/target-route.txt"
cd "${ROOT}"
go test ./core/frontend/nbd ./core/frontend/nvmerdma ./core/frontend/nvme ./cmd/blockvolume \
>"${ARTIFACT_DIR}/go-test.stdout.txt" 2>"${ARTIFACT_DIR}/go-test.stderr.txt"
write_summary "go_test_nbd_nvmerdma_nvme_blockvolume=ok"
write_summary "tcp_behavior_unchanged=true"
write_summary "rdma_not_published_to_csi=true"
go build -o "${BIN}/blockmaster" ./cmd/blockmaster
go build -o "${BIN}/blockvolume" ./cmd/blockvolume
printf '%s\n' \
'volumes:' \
' - volume_id: v1' \
' slots:' \
' - replica_id: r1' \
' server_id: s1' >"${WORK}/topology.yaml"
mkdir -p "${WORK}/master-store" "${WORK}/volume-store"
"${BIN}/blockmaster" \
--authority-store "${WORK}/master-store" \
--listen 127.0.0.1:16331 \
--topology "${WORK}/topology.yaml" \
--expected-slots-per-volume 1 \
--t0-print-ready \
>"${ARTIFACT_DIR}/blockmaster.log" 2>&1 &
MASTER_PID=$!
for _ in $(seq 1 100); do
grep -q '"phase":"listening"' "${ARTIFACT_DIR}/blockmaster.log" 2>/dev/null && break
kill -0 "${MASTER_PID}"
sleep 0.1
done
grep -q '"phase":"listening"' "${ARTIFACT_DIR}/blockmaster.log"
sudo "${BIN}/blockvolume" \
--master 127.0.0.1:16331 \
--server-id s1 \
--volume-id v1 \
--replica-id r1 \
--data-addr 127.0.0.1:16332 \
--ctrl-addr 127.0.0.1:16333 \
--status-addr 127.0.0.1:16334 \
--heartbeat-interval 200ms \
--t1-readiness \
--durable-root "${WORK}/volume-store" \
--durable-impl smartwal \
--durable-blocks 8192 \
--durable-blocksize 4096 \
--nvme-listen "${TARGET_IP}:${TARGET_PORT}" \
--nvme-transport rdma \
--allow-external-nvme-bind \
--nvme-subsysnqn "${NQN}" \
--nvme-ns 1 \
>"${ARTIFACT_DIR}/blockvolume.log" 2>&1 &
VOLUME_PID=$!
for _ in $(seq 1 300); do
if ! sudo kill -0 "${VOLUME_PID}" >/dev/null 2>&1; then
cat "${ARTIFACT_DIR}/blockvolume.log" >&2
exit 1
fi
grep -q '"phase":"nvme-listening"' "${ARTIFACT_DIR}/blockvolume.log" 2>/dev/null && break
sleep 0.1
done
grep -q '"phase":"nvme-listening"' "${ARTIFACT_DIR}/blockvolume.log"
for _ in $(seq 1 300); do
if curl -fsS 'http://127.0.0.1:16334/status?volume=v1' \
>"${ARTIFACT_DIR}/status.json" 2>/dev/null &&
grep -q '"FrontendPrimaryReady":true' "${ARTIFACT_DIR}/status.json"; then
break
fi
sleep 0.1
done
grep -q '"FrontendPrimaryReady":true' "${ARTIFACT_DIR}/status.json"
curl -fsS 'http://127.0.0.1:16334/status/frontend-capabilities?volume=v1' \
>"${ARTIFACT_DIR}/capabilities.json"
python3 - "${ARTIFACT_DIR}/capabilities.json" <<'PY'
import json, sys
doc = json.load(open(sys.argv[1]))
rdma = next(x for x in doc["frontendTransports"] if x["transport"] == "rdma")
tcp = next(x for x in doc["frontendTransports"] if x["transport"] == "tcp")
assert rdma["supported"] is True
assert rdma["listenerImplemented"] is True
assert rdma["listenerStarted"] is True
assert rdma["startAllowed"] is True
assert rdma["reason"] == "implemented"
assert tcp["supported"] is True
assert tcp["listenerStarted"] is False
PY
write_summary "capability_endpoint_reports_rdma_supported=true"
write_summary "rdma_listener_started=true"
NBD_PATH="$(cat "/sys/kernel/config/nvmet/subsystems/${NQN}/namespaces/1/device_path")"
[[ -b "${NBD_PATH}" ]]
write_summary "backend_bridge_device=${NBD_PATH}"
ssh -i "${HOST_SSH_KEY}" -o BatchMode=yes "${HOST_SSH_USER}@${HOST_SSH_ADDR}" \
"sudo bash -s" >"${ARTIFACT_DIR}/host-io.txt" <<HOST
set -euo pipefail
NQN='${NQN}'
nvme disconnect -n "\$NQN" >/dev/null 2>&1 || true
modprobe nvme-rdma
ip route get '${TARGET_IP}'
nvme connect -t rdma -a '${TARGET_IP}' -s '${TARGET_PORT}' -n "\$NQN"
DEV=''
for _ in \$(seq 1 100); do
for p in /sys/class/nvme-subsystem/*/subsysnqn; do
[[ -e "\$p" ]] || continue
if [[ "\$(cat "\$p")" == "\$NQN" ]]; then
base="\$(dirname "\$p")"
for candidate in "\$base"/nvme*n*; do
[[ -e "\$candidate" ]] || continue
DEV="/dev/\$(basename "\$candidate")"
break 2
done
fi
done
sleep 0.1
done
[[ -b "\$DEV" ]]
EXPECTED="\$(python3 -c 'import hashlib; print(hashlib.sha256((b"phase163-seaweed-rdma"*256)[:4096]).hexdigest())')"
python3 -c 'import sys; sys.stdout.buffer.write((b"phase163-seaweed-rdma"*256)[:4096])' | \
dd of="\$DEV" bs=4096 count=1 conv=fsync status=none
nvme flush "\$DEV" -n 1
ACTUAL="\$(dd if="\$DEV" bs=4096 count=1 status=none | sha256sum | awk '{print \$1}')"
[[ "\$ACTUAL" == "\$EXPECTED" ]]
nvme list-subsys -o json
nvme disconnect -n "\$NQN"
printf 'linux_nvme_connect_rdma_succeeded=true\nstandalone_write_read_verified=true\nflush_verified=true\nhost_device=%s\n' "\$DEV"
HOST
grep -q '^linux_nvme_connect_rdma_succeeded=true$' "${ARTIFACT_DIR}/host-io.txt"
grep -q '^standalone_write_read_verified=true$' "${ARTIFACT_DIR}/host-io.txt"
grep -q '^flush_verified=true$' "${ARTIFACT_DIR}/host-io.txt"
grep -a -q 'durable: write observer dispatch lba=0 lsn=' "${ARTIFACT_DIR}/blockvolume.log"
write_summary "linux_nvme_connect_rdma_succeeded=true"
write_summary "standalone_write_read_verified=true"
write_summary "flush_verified=true"
write_summary "seaweed_backend_write_observed=true"
cleanup
VOLUME_PID=""
MASTER_PID=""
trap - EXIT
[[ ! -e "/sys/kernel/config/nvmet/subsystems/${NQN}" ]]
[[ ! -e "/sys/kernel/config/nvmet/ports/${TARGET_PORT}" ]]
if [[ -n "${NBD_PATH}" && -e "/sys/block/$(basename "${NBD_PATH}")/pid" ]]; then
[[ ! -s "/sys/block/$(basename "${NBD_PATH}")/pid" ]]
fi
if ssh -i "${HOST_SSH_KEY}" -o BatchMode=yes "${HOST_SSH_USER}@${HOST_SSH_ADDR}" \
"sudo nvme list-subsys -o json" | grep -q "${NQN}"; then
echo "Phase 163 host controller residue remains for ${NQN}" >&2
exit 1
fi
write_summary "disconnect_cleanup_status=ok"
write_summary "cleanup_status=ok"
write_summary "phase163_decision=standalone_nvme_rdma_live_io_supported"
write_summary "next_recommendation=phase164_nvme_rdma_standalone_hardening"
write_summary "phase163_nvme_rdma_standalone_listener_impl_spike_status=ok"
@@ -0,0 +1,89 @@
name: nvme-rdma-standalone-live-chain
timeout: 20m
env:
product_root: "/tmp/seaweed_block"
ssh_key: "C:\\work\\dev_server\\testdev_key"
topology:
nodes:
m02:
host: 192.168.1.184
user: testdev
key: "{{ ssh_key }}"
phases:
- name: run_gate
actions:
- action: exec
node: m02
timeout: 15m
cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma && cd {{ product_root }} && SW_BLOCK_PHASE163_RUN_ID={{ run_id }} SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma bash scripts/run-phase163-nvme-rdma-standalone-live-gate.sh {{ product_root }}"
- name: assert_summary
actions:
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma/phase163-nvme-rdma-standalone-live-summary.txt"
pattern: "^phase163_nvme_rdma_standalone_listener_impl_spike_status=ok$"
save_as: phase163_ok
- action: assert_greater
actual: "{{ phase163_ok }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma/phase163-nvme-rdma-standalone-live-summary.txt"
pattern: "^linux_nvme_connect_rdma_succeeded=true$"
save_as: rdma_connect
- action: assert_greater
actual: "{{ rdma_connect }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma/phase163-nvme-rdma-standalone-live-summary.txt"
pattern: "^standalone_write_read_verified=true$"
save_as: rdma_io
- action: assert_greater
actual: "{{ rdma_io }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma/phase163-nvme-rdma-standalone-live-summary.txt"
pattern: "^seaweed_backend_write_observed=true$"
save_as: seaweed_backend
- action: assert_greater
actual: "{{ seaweed_backend }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma/phase163-nvme-rdma-standalone-live-summary.txt"
pattern: "^capability_endpoint_reports_rdma_supported=true$"
save_as: capability_supported
- action: assert_greater
actual: "{{ capability_supported }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma/phase163-nvme-rdma-standalone-live-summary.txt"
pattern: "^rdma_not_published_to_csi=true$"
save_as: no_csi_publish
- action: assert_greater
actual: "{{ no_csi_publish }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma/phase163-nvme-rdma-standalone-live-summary.txt"
pattern: "^disconnect_cleanup_status=ok$"
save_as: cleanup_ok
- action: assert_greater
actual: "{{ cleanup_ok }}"
threshold: "0"
- name: collect
always: true
actions:
- action: collect_path
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase163-nvme-rdma"
name: "remote-phases"
ignore_error: true