mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
Merge pull request #26 from seaweedfs/iscsi-p2/os-initiator-stability
fix(iscsi): harden Linux initiator data path
This commit is contained in:
commit
7af116df2f
9 files changed
+1025
-3
No files matched your search
@@ -0,0 +1,162 @@
|
||||
package iscsi_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"log"
|
||||
"runtime"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/iscsi"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/testback"
|
||||
)
|
||||
|
||||
type slowP2Backend struct {
|
||||
inner *testback.RecordingBackend
|
||||
writeDelay time.Duration
|
||||
writeCalls atomic.Int64
|
||||
}
|
||||
|
||||
func (b *slowP2Backend) Identity() frontend.Identity { return b.inner.Identity() }
|
||||
func (b *slowP2Backend) Close() error { return b.inner.Close() }
|
||||
func (b *slowP2Backend) SetOperational(ok bool, evidence string) {
|
||||
b.inner.SetOperational(ok, evidence)
|
||||
}
|
||||
func (b *slowP2Backend) Sync(ctx context.Context) error { return b.inner.Sync(ctx) }
|
||||
func (b *slowP2Backend) Read(ctx context.Context, offset int64, p []byte) (int, error) {
|
||||
return b.inner.Read(ctx, offset, p)
|
||||
}
|
||||
func (b *slowP2Backend) Write(ctx context.Context, offset int64, p []byte) (int, error) {
|
||||
b.writeCalls.Add(1)
|
||||
if b.writeDelay > 0 {
|
||||
time.Sleep(b.writeDelay)
|
||||
}
|
||||
return b.inner.Write(ctx, offset, p)
|
||||
}
|
||||
|
||||
func startP2MemoryTarget(t *testing.T, backend frontend.Backend, volumeSize uint64, maxBurst int) (*iscsi.Target, string) {
|
||||
t.Helper()
|
||||
neg := iscsi.DefaultNegotiableConfig()
|
||||
neg.MaxBurstLength = maxBurst
|
||||
neg.FirstBurstLength = maxBurst
|
||||
tg := iscsi.NewTarget(iscsi.TargetConfig{
|
||||
Listen: "127.0.0.1:0",
|
||||
IQN: "iqn.2026-04.example.v3:v1",
|
||||
VolumeID: "v1",
|
||||
Provider: testback.NewStaticProvider(backend),
|
||||
Handler: iscsi.HandlerConfig{VolumeSize: volumeSize},
|
||||
Negotiation: neg,
|
||||
Logger: log.New(io.Discard, "", 0),
|
||||
})
|
||||
addr, err := tg.Start()
|
||||
if err != nil {
|
||||
t.Fatalf("target Start: %v", err)
|
||||
}
|
||||
return tg, addr
|
||||
}
|
||||
|
||||
func currentHeapAlloc() uint64 {
|
||||
runtime.GC()
|
||||
var m runtime.MemStats
|
||||
runtime.ReadMemStats(&m)
|
||||
return m.HeapAlloc
|
||||
}
|
||||
|
||||
// TestP2_ISCSI_LargeWrite4MiB_DoesNotGrowHeapUnbounded ports the useful
|
||||
// part of V2's large-write memory guard to the V3 target. It exercises real
|
||||
// R2T chunking with several filesystem-sized writes, then checks that the
|
||||
// target is not retaining one assembled payload per completed command.
|
||||
func TestP2_ISCSI_LargeWrite4MiB_DoesNotGrowHeapUnbounded(t *testing.T) {
|
||||
const (
|
||||
writeBytes = 4 * 1024 * 1024
|
||||
blocks = writeBytes / int(iscsi.DefaultBlockSize)
|
||||
writes = 5
|
||||
maxBurst = 256 * 1024
|
||||
)
|
||||
|
||||
rec := testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1"})
|
||||
tg, addr := startP2MemoryTarget(t, rec, writeBytes*writes, maxBurst)
|
||||
defer tg.Close()
|
||||
|
||||
cli := dialAndLogin(t, addr)
|
||||
defer cli.logout(t)
|
||||
|
||||
payload := make([]byte, writeBytes)
|
||||
for i := range payload {
|
||||
payload[i] = byte((i * 31) % 251)
|
||||
}
|
||||
|
||||
before := currentHeapAlloc()
|
||||
for i := 0; i < writes; i++ {
|
||||
lba := uint32(i * blocks)
|
||||
status, _, traces := cli.scsiCmdFullWithR2TTrace(t, writeCDB10(lba, uint16(blocks)), nil, payload, 0)
|
||||
expectGood(t, status, "4MiB WRITE(10)")
|
||||
if len(traces) < 2 {
|
||||
t.Fatalf("write %d: R2T count=%d want multiple chunks", i, len(traces))
|
||||
}
|
||||
for j, tr := range traces {
|
||||
if tr.Desired > maxBurst {
|
||||
t.Fatalf("write %d R2T[%d] DesiredDataLength=%d exceeds MaxBurst=%d", i, j, tr.Desired, maxBurst)
|
||||
}
|
||||
}
|
||||
}
|
||||
after := currentHeapAlloc()
|
||||
deltaMB := int64(after-before) / (1024 * 1024)
|
||||
t.Logf("%d x 4MiB WRITE(10): heap delta=%d MB writes=%d", writes, deltaMB, rec.WriteCount())
|
||||
|
||||
if rec.WriteCount() != writes {
|
||||
t.Fatalf("backend WriteCount=%d want %d", rec.WriteCount(), writes)
|
||||
}
|
||||
if deltaMB > 160 {
|
||||
t.Fatalf("heap grew %d MB after %d x 4MiB iSCSI writes; likely retained Data-Out buffers", deltaMB, writes)
|
||||
}
|
||||
}
|
||||
|
||||
// TestP2_ISCSI_LargeWrite_SlowBackend_DoesNotAccumulateBuffers simulates a
|
||||
// backend that blocks briefly on each write, like a WAL admission or disk
|
||||
// flush stall. Completed commands should release their R2T/Data-Out buffers
|
||||
// even when backend writes are slower than the initiator's command loop.
|
||||
func TestP2_ISCSI_LargeWrite_SlowBackend_DoesNotAccumulateBuffers(t *testing.T) {
|
||||
const (
|
||||
writeBytes = 1 * 1024 * 1024
|
||||
blocks = writeBytes / int(iscsi.DefaultBlockSize)
|
||||
writes = 8
|
||||
maxBurst = 128 * 1024
|
||||
)
|
||||
|
||||
rec := testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1"})
|
||||
slow := &slowP2Backend{inner: rec, writeDelay: 25 * time.Millisecond}
|
||||
tg, addr := startP2MemoryTarget(t, slow, writeBytes*writes, maxBurst)
|
||||
defer tg.Close()
|
||||
|
||||
cli := dialAndLogin(t, addr)
|
||||
defer cli.logout(t)
|
||||
|
||||
payload := make([]byte, writeBytes)
|
||||
for i := range payload {
|
||||
payload[i] = byte((i * 17) % 251)
|
||||
}
|
||||
|
||||
before := currentHeapAlloc()
|
||||
for i := 0; i < writes; i++ {
|
||||
lba := uint32(i * blocks)
|
||||
status, _, traces := cli.scsiCmdFullWithR2TTrace(t, writeCDB10(lba, uint16(blocks)), nil, payload, 0)
|
||||
expectGood(t, status, "slow-backend WRITE(10)")
|
||||
if len(traces) < 2 {
|
||||
t.Fatalf("write %d: R2T count=%d want multiple chunks", i, len(traces))
|
||||
}
|
||||
}
|
||||
after := currentHeapAlloc()
|
||||
deltaMB := int64(after-before) / (1024 * 1024)
|
||||
t.Logf("%d x 1MiB slow WRITE(10): heap delta=%d MB writes=%d", writes, deltaMB, slow.writeCalls.Load())
|
||||
|
||||
if slow.writeCalls.Load() != writes {
|
||||
t.Fatalf("backend writeCalls=%d want %d", slow.writeCalls.Load(), writes)
|
||||
}
|
||||
if deltaMB > 96 {
|
||||
t.Fatalf("heap grew %d MB with slow backend; likely accumulating completed Data-Out buffers", deltaMB)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package iscsi_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/iscsi"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/testback"
|
||||
)
|
||||
|
||||
func startP2Target(t *testing.T) (*iscsi.Target, string, *testback.RecordingBackend) {
|
||||
t.Helper()
|
||||
rec := testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1"})
|
||||
tg := iscsi.NewTarget(iscsi.TargetConfig{
|
||||
Listen: "127.0.0.1:0",
|
||||
IQN: "iqn.2026-04.example.v3:v1",
|
||||
VolumeID: "v1",
|
||||
Provider: testback.NewStaticProvider(rec),
|
||||
Logger: log.New(io.Discard, "", 0),
|
||||
})
|
||||
addr, err := tg.Start()
|
||||
if err != nil {
|
||||
t.Fatalf("target Start: %v", err)
|
||||
}
|
||||
return tg, addr, rec
|
||||
}
|
||||
|
||||
func TestP2_ISCSI_ConcurrentSessions50_WriteRead(t *testing.T) {
|
||||
tg, addr, _ := startP2Target(t)
|
||||
defer tg.Close()
|
||||
|
||||
const sessions = 50
|
||||
errs := make(chan error, sessions)
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < sessions; i++ {
|
||||
wg.Add(1)
|
||||
go func(id int) {
|
||||
defer wg.Done()
|
||||
cli := dialAndLogin(t, addr)
|
||||
defer cli.logout(t)
|
||||
|
||||
payload := bytes.Repeat([]byte{byte(id)}, int(iscsi.DefaultBlockSize))
|
||||
status, _ := cli.scsiCmd(t, writeCDB10(uint32(id), 1), payload, 0)
|
||||
if status != iscsi.StatusGood {
|
||||
errs <- fmt.Errorf("session %d write status=0x%02x", id, status)
|
||||
return
|
||||
}
|
||||
status, got := cli.scsiCmd(t, readCDB10(uint32(id), 1), nil, int(iscsi.DefaultBlockSize))
|
||||
if status != iscsi.StatusGood {
|
||||
errs <- fmt.Errorf("session %d read status=0x%02x", id, status)
|
||||
return
|
||||
}
|
||||
if !bytes.Equal(got, payload) {
|
||||
errs <- fmt.Errorf("session %d read payload mismatch", id)
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errs)
|
||||
for err := range errs {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestP2_ISCSI_TargetCloseWithActiveSessions_ExitsCleanly(t *testing.T) {
|
||||
tg, addr, _ := startP2Target(t)
|
||||
|
||||
const sessions = 8
|
||||
clients := make([]*testClient, 0, sessions)
|
||||
for i := 0; i < sessions; i++ {
|
||||
clients = append(clients, dialAndLogin(t, addr))
|
||||
}
|
||||
|
||||
closed := make(chan error, 1)
|
||||
go func() { closed <- tg.Close() }()
|
||||
select {
|
||||
case err := <-closed:
|
||||
if err != nil {
|
||||
t.Fatalf("target Close: %v", err)
|
||||
}
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Fatal("target Close timed out with active sessions")
|
||||
}
|
||||
|
||||
for i, cli := range clients {
|
||||
_ = cli.conn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
||||
if _, err := iscsi.ReadPDU(cli.conn); err == nil {
|
||||
t.Fatalf("client %d: expected read error after target Close", i)
|
||||
}
|
||||
_ = cli.conn.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func TestP2_ISCSI_ErrorResponseAdvancesStatSN(t *testing.T) {
|
||||
tg, addr, _ := startP2Target(t)
|
||||
defer tg.Close()
|
||||
|
||||
cli := dialAndLogin(t, addr)
|
||||
defer cli.logout(t)
|
||||
|
||||
nop := &iscsi.PDU{}
|
||||
nop.SetOpcode(iscsi.OpNOPOut)
|
||||
nop.SetOpSpecific1(iscsi.FlagF)
|
||||
nop.SetImmediate(true)
|
||||
nop.SetInitiatorTaskTag(cli.itt)
|
||||
cli.itt++
|
||||
nop.SetCmdSN(cli.cmdSN)
|
||||
cli.cmdSN++
|
||||
if err := iscsi.WritePDU(cli.conn, nop); err != nil {
|
||||
t.Fatalf("write initial NOP-Out: %v", err)
|
||||
}
|
||||
nopResp, err := iscsi.ReadPDU(cli.conn)
|
||||
if err != nil {
|
||||
t.Fatalf("read initial NOP-In: %v", err)
|
||||
}
|
||||
if nopResp.Opcode() != iscsi.OpNOPIn {
|
||||
t.Fatalf("initial response opcode=%s want NOP-In", iscsi.OpcodeName(nopResp.Opcode()))
|
||||
}
|
||||
baseSN := nopResp.StatSN()
|
||||
|
||||
read := &iscsi.PDU{}
|
||||
read.SetOpcode(iscsi.OpSCSICmd)
|
||||
read.SetOpSpecific1(iscsi.FlagF | iscsi.FlagR)
|
||||
read.SetLUN(0)
|
||||
read.SetInitiatorTaskTag(cli.itt)
|
||||
cli.itt++
|
||||
read.SetExpectedDataTransferLength(uint32(iscsi.DefaultBlockSize))
|
||||
read.SetCmdSN(cli.cmdSN)
|
||||
cli.cmdSN++
|
||||
read.SetExpStatSN(baseSN + 1)
|
||||
var cdb [16]byte
|
||||
cdb[0] = iscsi.ScsiRead10
|
||||
binary.BigEndian.PutUint32(cdb[2:6], 0xFFFFFFF0)
|
||||
binary.BigEndian.PutUint16(cdb[7:9], 1)
|
||||
read.SetCDB(cdb)
|
||||
if err := iscsi.WritePDU(cli.conn, read); err != nil {
|
||||
t.Fatalf("write out-of-range READ: %v", err)
|
||||
}
|
||||
errResp, err := iscsi.ReadPDU(cli.conn)
|
||||
if err != nil {
|
||||
t.Fatalf("read error response: %v", err)
|
||||
}
|
||||
if errResp.Opcode() != iscsi.OpSCSIResp {
|
||||
t.Fatalf("error response opcode=%s want SCSIResp", iscsi.OpcodeName(errResp.Opcode()))
|
||||
}
|
||||
if errResp.SCSIStatusByte() != iscsi.StatusCheckCondition {
|
||||
t.Fatalf("error response status=0x%02x want CheckCondition", errResp.SCSIStatusByte())
|
||||
}
|
||||
if errResp.StatSN() != baseSN+1 {
|
||||
t.Fatalf("error StatSN=%d want %d", errResp.StatSN(), baseSN+1)
|
||||
}
|
||||
|
||||
nop2 := &iscsi.PDU{}
|
||||
nop2.SetOpcode(iscsi.OpNOPOut)
|
||||
nop2.SetOpSpecific1(iscsi.FlagF)
|
||||
nop2.SetImmediate(true)
|
||||
nop2.SetInitiatorTaskTag(cli.itt)
|
||||
cli.itt++
|
||||
nop2.SetCmdSN(cli.cmdSN)
|
||||
cli.cmdSN++
|
||||
nop2.SetExpStatSN(baseSN + 2)
|
||||
if err := iscsi.WritePDU(cli.conn, nop2); err != nil {
|
||||
t.Fatalf("write second NOP-Out: %v", err)
|
||||
}
|
||||
nop2Resp, err := iscsi.ReadPDU(cli.conn)
|
||||
if err != nil {
|
||||
t.Fatalf("read second NOP-In: %v", err)
|
||||
}
|
||||
if nop2Resp.StatSN() != baseSN+2 {
|
||||
t.Fatalf("post-error NOP StatSN=%d want %d", nop2Resp.StatSN(), baseSN+2)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package iscsi_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/iscsi"
|
||||
"github.com/seaweedfs/seaweed-block/core/storage/smartwal"
|
||||
)
|
||||
|
||||
type p2ProjectionView struct {
|
||||
proj frontend.Projection
|
||||
}
|
||||
|
||||
func (v p2ProjectionView) Projection() frontend.Projection { return v.proj }
|
||||
|
||||
// TestP2_ISCSI_SustainedWriteSyncCache_SurvivesSmartWALReopen pins the
|
||||
// product-backed write/flush path that Linux filesystems depend on:
|
||||
// WRITE(10) reaches durable.StorageBackend, SYNCHRONIZE CACHE reaches
|
||||
// storage.Sync, and synced blocks survive a clean close/reopen.
|
||||
func TestP2_ISCSI_SustainedWriteSyncCache_SurvivesSmartWALReopen(t *testing.T) {
|
||||
const (
|
||||
blockSize = 4096
|
||||
numBlocks = 128
|
||||
scsiBlocksPerIO = uint16(blockSize / int(iscsi.DefaultBlockSize))
|
||||
writeCount = 48
|
||||
syncEvery = 8
|
||||
maxBurst = 128 * 1024
|
||||
frontendByteSize = numBlocks * blockSize
|
||||
)
|
||||
|
||||
path := filepath.Join(t.TempDir(), "smartwal.bin")
|
||||
store, err := smartwal.CreateStore(path, numBlocks, blockSize)
|
||||
if err != nil {
|
||||
t.Fatalf("smartwal.CreateStore: %v", err)
|
||||
}
|
||||
|
||||
id := frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}
|
||||
view := p2ProjectionView{proj: frontend.Projection{
|
||||
VolumeID: id.VolumeID,
|
||||
ReplicaID: id.ReplicaID,
|
||||
Epoch: id.Epoch,
|
||||
EndpointVersion: id.EndpointVersion,
|
||||
Healthy: true,
|
||||
}}
|
||||
backend := durable.NewStorageBackend(store, view, id)
|
||||
backend.SetOperational(true, "p2 sustained sync test")
|
||||
|
||||
tg, addr := startP2MemoryTarget(t, backend, frontendByteSize, maxBurst)
|
||||
cli := dialAndLogin(t, addr)
|
||||
|
||||
expected := make(map[uint32][]byte, writeCount)
|
||||
for i := 0; i < writeCount; i++ {
|
||||
lba := uint32(i)
|
||||
payload := bytes.Repeat([]byte{byte(i + 1)}, blockSize)
|
||||
status, _, traces := cli.scsiCmdFullWithR2TTrace(t, writeCDB10(lba*uint32(scsiBlocksPerIO), scsiBlocksPerIO), nil, payload, 0)
|
||||
expectGood(t, status, "sustained WRITE(10)")
|
||||
if len(traces) == 0 {
|
||||
t.Fatalf("write %d: expected R2T path for 4KiB payload", i)
|
||||
}
|
||||
expected[lba] = payload
|
||||
|
||||
if (i+1)%syncEvery == 0 {
|
||||
status, _ := cli.scsiCmd(t, syncCacheCDB10(), nil, 0)
|
||||
expectGood(t, status, "SYNCHRONIZE CACHE(10)")
|
||||
}
|
||||
}
|
||||
status, _ := cli.scsiCmd(t, syncCacheCDB10(), nil, 0)
|
||||
expectGood(t, status, "final SYNCHRONIZE CACHE(10)")
|
||||
|
||||
cli.logout(t)
|
||||
if err := tg.Close(); err != nil {
|
||||
t.Fatalf("target Close: %v", err)
|
||||
}
|
||||
if err := store.Close(); err != nil {
|
||||
t.Fatalf("smartwal close: %v", err)
|
||||
}
|
||||
|
||||
reopened, err := smartwal.OpenStore(path)
|
||||
if err != nil {
|
||||
t.Fatalf("smartwal.OpenStore: %v", err)
|
||||
}
|
||||
defer reopened.Close()
|
||||
if _, err := reopened.Recover(); err != nil {
|
||||
t.Fatalf("smartwal Recover: %v", err)
|
||||
}
|
||||
|
||||
for _, lba := range []uint32{0, 7, 8, 23, 47} {
|
||||
got, err := reopened.Read(lba)
|
||||
if err != nil {
|
||||
t.Fatalf("reopened Read lba=%d: %v", lba, err)
|
||||
}
|
||||
if !bytes.Equal(got, expected[lba]) {
|
||||
t.Fatalf("reopened data mismatch at lba=%d", lba)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,11 +288,13 @@ Harness note:
|
||||
|
||||
```text
|
||||
V:\share\iscsi-p1\run-p1-iscsi-os.sh
|
||||
scripts/run-iscsi-os-smoke.sh
|
||||
```
|
||||
|
||||
This is a share-driven QA harness, not a repository script yet. It starts a
|
||||
single-slot blockmaster/blockvolume pair with a 256 MiB durable target, then
|
||||
drives Linux `iscsiadm`, `mkfs.ext4`, mount, payload checksum, and cleanup.
|
||||
The share-driven harness captured the original P1 evidence. The repository
|
||||
script is the repeatable developer/QA entrypoint. Both start a single-slot
|
||||
blockmaster/blockvolume pair with a 256 MiB durable target, then drive Linux
|
||||
`iscsiadm`, `mkfs.ext4`, mount, payload checksum, and cleanup.
|
||||
|
||||
### Slice F: Large READ / DataInWriter
|
||||
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
# iSCSI / Frontend V2 Coverage Gap Audit
|
||||
|
||||
Date: 2026-05-04
|
||||
Branch: `iscsi-p2/os-initiator-stability`
|
||||
Scope: compare V2 `weed/storage/blockvol` frontend coverage against V3 `seaweed-block` before adding more iSCSI-P2 product code.
|
||||
|
||||
## Goal
|
||||
|
||||
Do not port V2 code blindly. Use V2's test suite as a coverage inventory and decide which missing V3 tests would have prevented recent debug loops, especially the iSCSI OS-initiator large I/O issues.
|
||||
|
||||
## Source Inventory
|
||||
|
||||
V2 paths reviewed:
|
||||
|
||||
- `weed/storage/blockvol/iscsi/*_test.go`
|
||||
- `weed/storage/blockvol/nvme/*_test.go`
|
||||
- `weed/storage/blockvol/csi/*_test.go`
|
||||
- `weed/storage/blockvol/test/component/*`
|
||||
- `weed/storage/blockvol/testrunner/scenarios/*`
|
||||
|
||||
V3 paths compared:
|
||||
|
||||
- `core/frontend/iscsi/*_test.go`
|
||||
- `core/frontend/nvme/*_test.go`
|
||||
- `core/csi/*_test.go`
|
||||
- `cmd/blockcsi/*_test.go`
|
||||
- `cmd/blockvolume/*_test.go`
|
||||
- `internal/docs/iscsi-os-initiator-compat-plan.md`
|
||||
|
||||
## What V3 Already Covers Well
|
||||
|
||||
### iSCSI protocol basics
|
||||
|
||||
V3 has good coverage for:
|
||||
|
||||
- PDU framing, AHS, data segment size, truncation.
|
||||
- Login direct-to-FFP and staged negotiation.
|
||||
- Discovery session basics and SendTargets.
|
||||
- Basic SCSI READ/WRITE, stale backend, closed backend, unknown opcode.
|
||||
- INQUIRY, VPD 0x80/0x83, READ CAPACITY 10/16, MODE SENSE, SYNC CACHE.
|
||||
- Endpoint version / stale lineage fail-closed.
|
||||
|
||||
Representative V3 tests:
|
||||
|
||||
- `core/frontend/iscsi/pdu_test.go`
|
||||
- `core/frontend/iscsi/login_test.go`
|
||||
- `core/frontend/iscsi/discovery_test.go`
|
||||
- `core/frontend/iscsi/scsi_test.go`
|
||||
- `core/frontend/iscsi/scsi_batch10_5_test.go`
|
||||
- `core/frontend/iscsi/t2_route_iscsi_test.go`
|
||||
|
||||
### Recent OS-initiator compatibility fixes
|
||||
|
||||
V3 now has focused P1 coverage for the bug class that blocked the demo:
|
||||
|
||||
- Large WRITE R2T path.
|
||||
- Data-Out collector checks DataSN, BufferOffset, TTT, overflow, premature final.
|
||||
- Bounded pending queue while collecting Data-Out.
|
||||
- Data-Out timeout.
|
||||
- Large READ split into bounded Data-In PDUs.
|
||||
- Residual count plus underflow/overflow direction flags.
|
||||
|
||||
Representative V3 tests:
|
||||
|
||||
- `core/frontend/iscsi/t2_large_write_test.go`
|
||||
- `core/frontend/iscsi/dataout_test.go`
|
||||
- `core/frontend/iscsi/p1_os_initiator_test.go`
|
||||
- `core/frontend/iscsi/p1_large_read_test.go`
|
||||
- `core/frontend/iscsi/datain_test.go`
|
||||
|
||||
## High-Value Gaps From V2
|
||||
|
||||
### Gap 1: iSCSI RX/TX session stress
|
||||
|
||||
V2 has a dedicated `qa_rxtx_test.go` suite covering:
|
||||
|
||||
- Response-channel backpressure.
|
||||
- Double session close.
|
||||
- Tx-loop goroutine leak.
|
||||
- 50 concurrent sessions.
|
||||
- SCSI command during Data-Out.
|
||||
- NOP-Out during Data-Out and response ordering.
|
||||
- StatSN monotonicity and error-response StatSN.
|
||||
- Target close while I/O is active.
|
||||
- New session after target close.
|
||||
|
||||
V3 has partial coverage:
|
||||
|
||||
- SCSI command during Data-Out is covered in `TestP1_ISCSI_R2TDataOut_AllowsPipelinedCommand`.
|
||||
- Pending queue bounded is covered.
|
||||
- Data-Out timeout is covered.
|
||||
|
||||
V3 still lacks a compact RX/TX stress pack:
|
||||
|
||||
- 50 concurrent sessions.
|
||||
- target close during active I/O.
|
||||
- double close no panic.
|
||||
- StatSN after error response.
|
||||
- NOP-Out pending ordering.
|
||||
- goroutine leak budget across many connect/login/logout cycles.
|
||||
|
||||
Priority: **P2 high**. These are low-cost in-process tests and can catch correctness regressions before hardware.
|
||||
|
||||
### Gap 2: large-write memory pressure and slow backend
|
||||
|
||||
V2 has `large_write_mem_test.go`:
|
||||
|
||||
- `TestLargeWriteMemory_4MB`: 10 x 4 MiB writes through a real iSCSI session and heap growth check.
|
||||
- `TestLargeWriteMemory_SlowDevice`: slow `WriteAt` simulates WAL/admission pressure and checks buffers do not accumulate.
|
||||
|
||||
V3 has large WRITE protocol tests but not an equivalent memory/slow-backend guard.
|
||||
|
||||
Priority: **P2 high**. This directly matches the demo failure class. Add a V3 test with a fake backend that sleeps and tracks heap/goroutines.
|
||||
|
||||
### Gap 3: product-backed iSCSI stability
|
||||
|
||||
V2 `qa_stability_test.go` covers iSCSI over a real block volume:
|
||||
|
||||
- sustained 1000 writes.
|
||||
- write/read under WAL pressure.
|
||||
- SYNC CACHE under pressure.
|
||||
- multiple sessions sharing one volume.
|
||||
- crash recovery via iSCSI.
|
||||
- session reconnect.
|
||||
- rapid open/close target.
|
||||
- extreme valid config values.
|
||||
|
||||
V3 has product-level K8s/CSI smoke and blockvolume L2 tests, but not this exact "frontend over durable backend under pressure" pack.
|
||||
|
||||
Priority: **P2/P3 medium-high**. This should be adapted to V3 durable backend semantics, not copied mechanically from V2.
|
||||
|
||||
### Gap 4: CHAP
|
||||
|
||||
V2 has `auth_test.go` and `qa_chap_test.go`:
|
||||
|
||||
- CHAP config validation.
|
||||
- challenge/response state machine.
|
||||
- wrong username/password.
|
||||
- replayed challenge rejected.
|
||||
- login integration with missing CHAP_N / CHAP_R.
|
||||
|
||||
V3 does not implement CHAP.
|
||||
|
||||
Priority: **iSCSI-P4**, not P2. Security is product-important but should not block basic single-path protocol correctness.
|
||||
|
||||
### Gap 5: ALUA / MPIO foundation
|
||||
|
||||
V2 has `alua.go` and `qa_alua_test.go`:
|
||||
|
||||
- standby metadata commands allowed.
|
||||
- unavailable/transitioning reject writes.
|
||||
- active allows all ops.
|
||||
- state change mid-stream fences the next write.
|
||||
- VPD 0x83 / REPORT TARGET PORT GROUPS.
|
||||
- concurrent state reads and standby reject.
|
||||
|
||||
V3 does not implement ALUA.
|
||||
|
||||
Priority: **iSCSI-P6**. This belongs after the HA/frontend fact model is stable. Do not mix it into P2.
|
||||
|
||||
### Gap 6: CSI node lifecycle hardening
|
||||
|
||||
V2 CSI tests are much broader than V3:
|
||||
|
||||
- NodeStage/NodeUnstage idempotency.
|
||||
- login failure cleanup.
|
||||
- mkfs failure cleanup.
|
||||
- unstage retry preserves staged entry.
|
||||
- restart fallback using transport files.
|
||||
- expand behavior.
|
||||
- wrong volume at staging path.
|
||||
- concurrent stage/unstage.
|
||||
- NVMe vs iSCSI transport stickiness.
|
||||
|
||||
V3 has the alpha K8s dynamic PVC path and some controller/node basics, but not the full adversarial node lifecycle matrix.
|
||||
|
||||
Priority: **K8s/CSI-P2**, separate from iSCSI-P2. These tests matter before public alpha hardening.
|
||||
|
||||
### Gap 7: NVMe QA breadth
|
||||
|
||||
V2 NVMe has extensive coverage:
|
||||
|
||||
- wire truncation and malformed PDUs.
|
||||
- connect sequencing.
|
||||
- admin / IO queue separation.
|
||||
- large read chunking.
|
||||
- ANA behavior.
|
||||
- concurrent IO.
|
||||
- reconnect/disconnect loops.
|
||||
- buffer pool safety.
|
||||
- WAL pressure classification.
|
||||
|
||||
V3 NVMe has a solid initial port but less breadth.
|
||||
|
||||
Priority: **NVMe-P2+**. Do not block iSCSI-P2, but use the same audit method before claiming NVMe product readiness.
|
||||
|
||||
## First V3 Tests To Add Before More Product Code
|
||||
|
||||
### Test Slice A: iSCSI RX/TX session stability pack
|
||||
|
||||
Add a V3 test file, likely:
|
||||
|
||||
- `core/frontend/iscsi/p2_rxtx_stability_test.go`
|
||||
|
||||
Initial tests:
|
||||
|
||||
- `TestP2_ISCSI_RapidLoginLogout_NoGoroutineLeak`
|
||||
- `TestP2_ISCSI_ConcurrentSessions50_WriteRead`
|
||||
- `TestP2_ISCSI_TargetCloseDuringActiveIO_ExitsCleanly`
|
||||
- `TestP2_ISCSI_NopDuringDataOut_DrainsAfterWrite`
|
||||
- `TestP2_ISCSI_ErrorResponseAdvancesStatSN`
|
||||
|
||||
Rationale: this is cheap, local, and directly protects the new pending-queue/Data-Out/Data-In state machine.
|
||||
|
||||
### Test Slice B: large write memory / slow backend
|
||||
|
||||
Add:
|
||||
|
||||
- `TestP2_ISCSI_LargeWrite4MiB_DoesNotGrowHeapUnbounded`
|
||||
- `TestP2_ISCSI_LargeWrite_SlowBackend_DoesNotAccumulateBuffers`
|
||||
|
||||
Keep thresholds loose enough for CI, but strict enough to catch unbounded buffering.
|
||||
|
||||
Rationale: this would likely have exposed the original large WRITE issue before the Windows/Linux demo attempt.
|
||||
|
||||
### Test Slice C: real OS initiator harness
|
||||
|
||||
Add a harness, not necessarily a normal Go unit test:
|
||||
|
||||
```text
|
||||
Linux iscsiadm -> 256MiB/1GiB target -> mkfs.ext4 -> mount -> fio/dd read/write -> sha256 verify -> logout -> no sessions
|
||||
```
|
||||
|
||||
Rationale: in-process clients do not perfectly model Linux kernel iSCSI behavior. P1 already proved this.
|
||||
|
||||
## What Not To Do Now
|
||||
|
||||
- Do not port V2 CHAP/ALUA into P2.
|
||||
- Do not claim MPIO or mounted failover.
|
||||
- Do not copy V2 blockvol internals into V3 storage/authority layers.
|
||||
- Do not expand K8s operator cleanup while iSCSI single-path filesystem stability is still under verification.
|
||||
|
||||
## Recommended Order
|
||||
|
||||
1. Add Test Slice A: RX/TX session stability pack.
|
||||
2. Add Test Slice B: large-write memory / slow backend.
|
||||
3. Add Test Slice C: real OS initiator harness and run on M02. Keep the
|
||||
default single-iteration path cheap, but support repeated
|
||||
`SW_BLOCK_ISCSI_ITERATIONS=N` login/mkfs/mount/logout loops for session
|
||||
reconnect stability. Use `SW_BLOCK_ISCSI_STRESS=fio` or `dd` for sustained
|
||||
filesystem write/read pressure once the basic loop is green.
|
||||
4. Only then raise K8s alpha PVC size from toy/smoke scale to 256MiB/1GiB.
|
||||
5. Track CHAP as iSCSI-P4, ALUA/MPIO as iSCSI-P6.
|
||||
|
||||
## Decision
|
||||
|
||||
Proceed with **tests first** on `iscsi-p2/os-initiator-stability`.
|
||||
|
||||
The next implementation PR should not be a protocol refactor unless one of the P2 tests turns red and points to a concrete state-machine gap.
|
||||
@@ -172,6 +172,45 @@ func TestG15eK8sDynamicCleanupRegistrationBuildsShellDriver(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestISCSIP2OSSmokeRegistrationBuildsShellDriver(t *testing.T) {
|
||||
repoRoot := findRepoRoot(t)
|
||||
raw, err := os.Open(registrationPath(repoRoot, "iscsi-p2-os-smoke.json"))
|
||||
if err != nil {
|
||||
t.Fatalf("open registration: %v", err)
|
||||
}
|
||||
defer raw.Close()
|
||||
|
||||
registration, err := DecodeRegistration(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("DecodeRegistration: %v", err)
|
||||
}
|
||||
if registration.Scenario != "iscsi-p2-os-smoke" || registration.Driver.Type != "shell" {
|
||||
t.Fatalf("registration=%+v", registration)
|
||||
}
|
||||
if registration.KnownGreenCommit != "d25e7b4" {
|
||||
t.Fatalf("known_green_commit=%q want d25e7b4", registration.KnownGreenCommit)
|
||||
}
|
||||
driver, err := registration.NewDriver(repoRoot)
|
||||
if err != nil {
|
||||
t.Fatalf("NewDriver: %v", err)
|
||||
}
|
||||
shell, ok := driver.(ShellDriver)
|
||||
if !ok {
|
||||
t.Fatalf("driver type=%T want ShellDriver", driver)
|
||||
}
|
||||
if !filepath.IsAbs(shell.Path) || filepath.Base(shell.Path) != "run-iscsi-os-smoke.sh" {
|
||||
t.Fatalf("shell path=%q", shell.Path)
|
||||
}
|
||||
if _, err := os.Stat(shell.Path); err != nil {
|
||||
t.Fatalf("shell driver path missing: %v", err)
|
||||
}
|
||||
for _, want := range []string{"mkfs.iter1.log", "sha256-check.iter1.log", "fio.iter1.log", "iscsi-sessions.final.txt"} {
|
||||
if !containsString(registration.Artifacts, want) {
|
||||
t.Fatalf("registration artifacts missing %q: %v", want, registration.Artifacts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func containsString(values []string, want string) bool {
|
||||
for _, value := range values {
|
||||
if value == want {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"scenario": "iscsi-p2-os-smoke",
|
||||
"gate": "iSCSI-P2",
|
||||
"layer": "L3-privileged-host",
|
||||
"driver": {
|
||||
"type": "shell",
|
||||
"path": "scripts/run-iscsi-os-smoke.sh"
|
||||
},
|
||||
"default_timeout_s": 300,
|
||||
"required_capabilities": [
|
||||
"bash",
|
||||
"linux",
|
||||
"sudo",
|
||||
"iscsiadm",
|
||||
"iscsi_tcp-loadable",
|
||||
"mkfs.ext4",
|
||||
"mount",
|
||||
"sha256sum",
|
||||
"fio-optional"
|
||||
],
|
||||
"qa_instruction": "internal/docs/iscsi-os-initiator-compat-plan.md",
|
||||
"known_green_commit": "d25e7b4",
|
||||
"artifacts": [
|
||||
"run.log",
|
||||
"git-head.txt",
|
||||
"topology.yaml",
|
||||
"blockmaster.log",
|
||||
"blockvolume.log",
|
||||
"iscsi-sessions.before.txt",
|
||||
"discovery.iter1.log",
|
||||
"login.iter1.log",
|
||||
"lsblk.iter1.txt",
|
||||
"mkfs.iter1.log",
|
||||
"payload.iter1.sha256",
|
||||
"sha256-check.iter1.log",
|
||||
"fio.iter1.log",
|
||||
"dd.iter1.log",
|
||||
"logout.iter1.log",
|
||||
"iscsi-sessions.iter1.txt",
|
||||
"iscsi-sessions.final.txt",
|
||||
"iscsi-sessions.after.txt",
|
||||
"cleanup.log"
|
||||
],
|
||||
"non_claims": [
|
||||
"Single-host Linux initiator only.",
|
||||
"Single replica and single iSCSI session only.",
|
||||
"No CHAP, ALUA, MPIO, or mounted-volume failover claim.",
|
||||
"No Windows initiator claim.",
|
||||
"No performance, soak, or multi-client claim.",
|
||||
"No Kubernetes CSI claim; K8s is covered by separate G15 scenarios."
|
||||
]
|
||||
}
|
||||
@@ -9,6 +9,7 @@ This directory contains developer and QA helper scripts.
|
||||
| `run-k8s-alpha.sh` | Public alpha smoke wrapper. Prefer this in README/user docs. |
|
||||
| `build-alpha-images.sh` | Builds local Docker images used by the Kubernetes alpha harness. |
|
||||
| `run-alpha-k8s-dynamic.sh` | Public dynamic PVC alpha smoke entry. |
|
||||
| `run-iscsi-os-smoke.sh` | Privileged Linux OS-initiator smoke: `iscsiadm` -> `mkfs.ext4` -> mount -> checksum -> logout on a 256 MiB target. |
|
||||
| `build-g15b-images.sh` | Compatibility wrapper for older QA scripts. |
|
||||
| `run-g15b-k8s-static.sh` | Historical static PV Kubernetes harness. |
|
||||
| `run-g15d-k8s-dynamic.sh` | Historical dynamic PVC harness used by compatibility scenarios. |
|
||||
|
||||
Executable
+226
@@ -0,0 +1,226 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
RUN_ID="${RUN_ID:-$(date -u +%Y%m%dT%H%M%SZ)}"
|
||||
WORK_DIR="${SW_BLOCK_ISCSI_WORK_DIR:-/tmp/sw-block-iscsi-os}"
|
||||
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${WORK_DIR}/runs/${RUN_ID}}"
|
||||
IQN="${SW_BLOCK_ISCSI_IQN:-iqn.2026-05.io.seaweedfs:os-smoke-v1}"
|
||||
PORT="${SW_BLOCK_ISCSI_PORT:-3267}"
|
||||
MOUNT_DIR="${SW_BLOCK_ISCSI_MOUNT_DIR:-${WORK_DIR}/mnt}"
|
||||
MASTER_ADDR="${SW_BLOCK_MASTER_ADDR:-127.0.0.1:19333}"
|
||||
DATA_ADDR="${SW_BLOCK_DATA_ADDR:-127.0.0.1:19101}"
|
||||
CTRL_ADDR="${SW_BLOCK_CTRL_ADDR:-127.0.0.1:19102}"
|
||||
STATUS_ADDR="${SW_BLOCK_STATUS_ADDR:-127.0.0.1:19103}"
|
||||
BLOCKS="${SW_BLOCK_DURABLE_BLOCKS:-65536}" # 256 MiB at 4 KiB.
|
||||
BLOCK_SIZE="${SW_BLOCK_DURABLE_BLOCKSIZE:-4096}"
|
||||
ITERATIONS="${SW_BLOCK_ISCSI_ITERATIONS:-1}"
|
||||
STRESS="${SW_BLOCK_ISCSI_STRESS:-none}" # none | fio | dd
|
||||
FIO_SIZE="${SW_BLOCK_ISCSI_FIO_SIZE:-32m}"
|
||||
FIO_RUNTIME="${SW_BLOCK_ISCSI_FIO_RUNTIME:-10}"
|
||||
|
||||
BIN_DIR="${SW_BLOCK_BIN_DIR:-${WORK_DIR}/bin}"
|
||||
RUN_DIR="${WORK_DIR}/run"
|
||||
DEVLINK_GLOB="/dev/disk/by-path/*ip-127.0.0.1:${PORT}-iscsi-${IQN}-lun-0"
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR" "$BIN_DIR" "$RUN_DIR" "$MOUNT_DIR"
|
||||
|
||||
log() {
|
||||
printf '[iscsi-os] %s\n' "$*" | tee -a "$ARTIFACT_DIR/run.log"
|
||||
}
|
||||
|
||||
require_cmd() {
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
echo "missing required command: $1" >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
set +e
|
||||
log "cleanup"
|
||||
mountpoint -q "$MOUNT_DIR" && sudo umount "$MOUNT_DIR" >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true
|
||||
pkill -TERM -f "${BIN_DIR}/blockvolume" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true
|
||||
pkill -TERM -f "${BIN_DIR}/blockmaster" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true
|
||||
sleep 1
|
||||
pkill -KILL -f "${BIN_DIR}/blockvolume" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true
|
||||
pkill -KILL -f "${BIN_DIR}/blockmaster" >>"$ARTIFACT_DIR/cleanup.log" 2>&1 || true
|
||||
sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.after.txt" 2>&1 || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
require_cmd sudo
|
||||
require_cmd iscsiadm
|
||||
require_cmd mkfs.ext4
|
||||
require_cmd mount
|
||||
require_cmd sha256sum
|
||||
if [[ "$STRESS" == "fio" ]]; then
|
||||
require_cmd fio
|
||||
fi
|
||||
|
||||
log "run_id=$RUN_ID"
|
||||
log "root=$ROOT"
|
||||
log "artifact_dir=$ARTIFACT_DIR"
|
||||
log "iqn=$IQN"
|
||||
log "portal=127.0.0.1:${PORT}"
|
||||
log "size_blocks=${BLOCKS} block_size=${BLOCK_SIZE}"
|
||||
log "iterations=${ITERATIONS}"
|
||||
log "stress=${STRESS}"
|
||||
|
||||
cd "$ROOT"
|
||||
git rev-parse --short HEAD >"$ARTIFACT_DIR/git-head.txt" 2>/dev/null || true
|
||||
|
||||
if [[ -x "${BIN_DIR}/blockmaster" && -x "${BIN_DIR}/blockvolume" ]]; then
|
||||
log "use prebuilt binaries from ${BIN_DIR}"
|
||||
else
|
||||
require_cmd go
|
||||
log "build binaries"
|
||||
go build -o "${BIN_DIR}/blockmaster" ./cmd/blockmaster
|
||||
go build -o "${BIN_DIR}/blockvolume" ./cmd/blockvolume
|
||||
fi
|
||||
|
||||
cat >"$ARTIFACT_DIR/topology.yaml" <<YAML
|
||||
volumes:
|
||||
- volume_id: v1
|
||||
slots:
|
||||
- replica_id: r1
|
||||
server_id: s1
|
||||
YAML
|
||||
|
||||
rm -rf "${RUN_DIR}/master-store" "${RUN_DIR}/volume-store"
|
||||
mkdir -p "${RUN_DIR}/master-store" "${RUN_DIR}/volume-store"
|
||||
pkill -KILL -f "${BIN_DIR}/blockvolume" >/dev/null 2>&1 || true
|
||||
pkill -KILL -f "${BIN_DIR}/blockmaster" >/dev/null 2>&1 || true
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout >/dev/null 2>&1 || true
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >/dev/null 2>&1 || true
|
||||
sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.before.txt" 2>&1 || true
|
||||
|
||||
log "start blockmaster"
|
||||
setsid -f "${BIN_DIR}/blockmaster" \
|
||||
--authority-store "${RUN_DIR}/master-store" \
|
||||
--listen "$MASTER_ADDR" \
|
||||
--topology "$ARTIFACT_DIR/topology.yaml" \
|
||||
--expected-slots-per-volume 1 \
|
||||
>"$ARTIFACT_DIR/blockmaster.log" 2>&1
|
||||
sleep 1
|
||||
|
||||
log "start blockvolume iSCSI target"
|
||||
setsid -f "${BIN_DIR}/blockvolume" \
|
||||
--master "$MASTER_ADDR" \
|
||||
--server-id s1 \
|
||||
--volume-id v1 \
|
||||
--replica-id r1 \
|
||||
--data-addr "$DATA_ADDR" \
|
||||
--ctrl-addr "$CTRL_ADDR" \
|
||||
--status-addr "$STATUS_ADDR" \
|
||||
--heartbeat-interval 200ms \
|
||||
--t1-readiness \
|
||||
--durable-root "${RUN_DIR}/volume-store" \
|
||||
--durable-impl smartwal \
|
||||
--durable-blocks "$BLOCKS" \
|
||||
--durable-blocksize "$BLOCK_SIZE" \
|
||||
--iscsi-listen "127.0.0.1:${PORT}" \
|
||||
--iscsi-iqn "$IQN" \
|
||||
>"$ARTIFACT_DIR/blockvolume.log" 2>&1
|
||||
|
||||
log "wait iSCSI listener"
|
||||
for _ in $(seq 1 100); do
|
||||
if bash -c "</dev/tcp/127.0.0.1/${PORT}" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
bash -c "</dev/tcp/127.0.0.1/${PORT}" >/dev/null 2>&1
|
||||
sleep 2
|
||||
|
||||
run_iteration() {
|
||||
local iter="$1"
|
||||
local suffix="iter${iter}"
|
||||
|
||||
log "iteration ${iter}: iscsi discovery/login"
|
||||
sudo iscsiadm -m discovery -t sendtargets -p "127.0.0.1:${PORT}" | tee "$ARTIFACT_DIR/discovery.${suffix}.log"
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --login | tee "$ARTIFACT_DIR/login.${suffix}.log"
|
||||
|
||||
log "iteration ${iter}: wait kernel block device"
|
||||
local dev=""
|
||||
for _ in $(seq 1 100); do
|
||||
dev="$(ls $DEVLINK_GLOB 2>/dev/null | head -n1 || true)"
|
||||
if [[ -n "$dev" ]]; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
if [[ -z "$dev" ]]; then
|
||||
ls -l /dev/disk/by-path >"$ARTIFACT_DIR/by-path.${suffix}.txt" 2>&1 || true
|
||||
dmesg | tail -n 120 >"$ARTIFACT_DIR/dmesg.${suffix}.tail.txt" 2>&1 || true
|
||||
echo "device not found for IQN ${IQN} on iteration ${iter}" >&2
|
||||
exit 1
|
||||
fi
|
||||
local real_dev
|
||||
real_dev="$(readlink -f "$dev")"
|
||||
log "iteration ${iter}: device=$dev real=$real_dev"
|
||||
lsblk "$real_dev" >"$ARTIFACT_DIR/lsblk.${suffix}.txt" 2>&1 || true
|
||||
|
||||
log "iteration ${iter}: mkfs.ext4"
|
||||
sudo mkfs.ext4 -F "$real_dev" >"$ARTIFACT_DIR/mkfs.${suffix}.log" 2>&1
|
||||
|
||||
log "iteration ${iter}: mount/write/read"
|
||||
sudo mount "$real_dev" "$MOUNT_DIR"
|
||||
sudo dd if=/dev/urandom of="$MOUNT_DIR/payload.${suffix}.bin" bs=4096 count=8 status=none
|
||||
sync
|
||||
sudo sha256sum "$MOUNT_DIR/payload.${suffix}.bin" | tee "$ARTIFACT_DIR/payload.${suffix}.sha256"
|
||||
sudo sha256sum -c "$ARTIFACT_DIR/payload.${suffix}.sha256" | tee "$ARTIFACT_DIR/sha256-check.${suffix}.log"
|
||||
|
||||
case "$STRESS" in
|
||||
none)
|
||||
;;
|
||||
fio)
|
||||
log "iteration ${iter}: fio randrw stress"
|
||||
sudo fio \
|
||||
--name="sw-block-${suffix}" \
|
||||
--directory="$MOUNT_DIR" \
|
||||
--filename="fio-${suffix}.dat" \
|
||||
--size="$FIO_SIZE" \
|
||||
--rw=randrw \
|
||||
--rwmixread=50 \
|
||||
--bs=4k \
|
||||
--ioengine=sync \
|
||||
--direct=0 \
|
||||
--fsync=1 \
|
||||
--runtime="$FIO_RUNTIME" \
|
||||
--time_based \
|
||||
--group_reporting \
|
||||
--output="$ARTIFACT_DIR/fio.${suffix}.log"
|
||||
;;
|
||||
dd)
|
||||
log "iteration ${iter}: dd sequential stress"
|
||||
sudo dd if=/dev/urandom of="$MOUNT_DIR/dd-${suffix}.bin" bs=1M count=32 conv=fsync status=none 2>"$ARTIFACT_DIR/dd.${suffix}.log"
|
||||
;;
|
||||
*)
|
||||
echo "unsupported SW_BLOCK_ISCSI_STRESS=${STRESS} (want none, fio, or dd)" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
sudo umount "$MOUNT_DIR"
|
||||
|
||||
log "iteration ${iter}: logout"
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" --logout | tee "$ARTIFACT_DIR/logout.${suffix}.log"
|
||||
sudo iscsiadm -m node -T "$IQN" -p "127.0.0.1:${PORT}" -o delete >>"$ARTIFACT_DIR/logout.${suffix}.log" 2>&1 || true
|
||||
sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.${suffix}.txt" 2>&1 || true
|
||||
if ! grep -q "No active sessions" "$ARTIFACT_DIR/iscsi-sessions.${suffix}.txt"; then
|
||||
cat "$ARTIFACT_DIR/iscsi-sessions.${suffix}.txt"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
for iter in $(seq 1 "$ITERATIONS"); do
|
||||
run_iteration "$iter"
|
||||
done
|
||||
|
||||
cp "$ARTIFACT_DIR/iscsi-sessions.iter${ITERATIONS}.txt" "$ARTIFACT_DIR/iscsi-sessions.final.txt"
|
||||
|
||||
log "PASS: ${ITERATIONS} x iscsiadm mkfs mount write/read logout"
|
||||
log "artifacts=$ARTIFACT_DIR"
|
||||
Reference in new issue
Block a user