G5-5 instrumentation: SCSI handler + StorageBackend.Write entry

QA round 9 confirmed: even durable: write observer line is missing.
The iSCSI WRITE never reaches StorageBackend.writeBytes. Need to
walk further upstream — either the iSCSI handler isn't getting the
SCSI WRITE command, or it's getting it but using the wrong backend.

Add 6 instrumentation lines across two layers:

  core/frontend/iscsi/scsi.go (doWrite):
    - SCSI WRITE handler entry (fires on every WRITE_10/16 arrival)
    - SCSI WRITE rejected (LBA out of range)
    - SCSI WRITE rejected (short dataOut)
    - SCSI WRITE backend.Write FAILED
    - SCSI WRITE backend.Write ok

  core/frontend/iscsi/scsi.go (handleSCSI SYNC_CACHE branch):
    - SCSI SYNCHRONIZE_CACHE handler entry
    - SCSI SYNCHRONIZE_CACHE backend.Sync FAILED
    - SCSI SYNCHRONIZE_CACHE backend.Sync ok

  core/frontend/durable/storage_adapter.go (Write):
    - StorageBackend.Write entry (every Write call)
    - StorageBackend.Write gate-rejected (gate() returned err)

Disambiguation matrix for QA's next run:

  No 'iscsi: SCSI WRITE handler' line:
    → iSCSI session/login layer rejects command before SCSI handler.
       Check if Normal session established correctly; check whether
       initiator's volume sees the right size via READ_CAPACITY.

  iscsi: SCSI WRITE handler line present, but no
  durable: StorageBackend.Write entry:
    → SCSI handler reaches a DIFFERENT backend instance (not the
       observer-wired StorageBackend). Wiring fix in main.go required.

  iscsi: SCSI WRITE handler + durable: StorageBackend.Write entry,
  but no observer dispatch:
    → backend gate() rejected (closed/non-operational/lineage drift).
       gate-rejected line fires.

  All instrumentation fires through to ship/barrier:
    → Replication is working.

Tests still green: iscsi (30.9s), durable (0.5s), blockvolume (16.7s).

Refs: QA round 9 — observer line missing from upstream
instrumentation; need iSCSI-side disambiguation.
This commit is contained in:
pingqiu committed 2026-04-27 01:06:57 -07:00
1 parent c6bace4e79
commit 4ec7bd0c2e
2 files changed
+22

No files matched your search

@@ -241,7 +241,14 @@ func (b *StorageBackend) Read(ctx context.Context, offset int64, p []byte) (int,
// overlay the partial range, write the full block back.
// Every write is gated.
func (b *StorageBackend) Write(ctx context.Context, offset int64, p []byte) (int, error) {
// G5-5 instrumentation: log every Write entry. If this line
// doesn't appear when the iSCSI initiator writes, the iSCSI
// handler is NOT calling our StorageBackend.Write (= bigger
// wiring gap, potentially using a different backend instance
// or bypassing the durable layer entirely).
log.Printf("durable: StorageBackend.Write entry offset=%d len=%d", offset, len(p))
if err := b.gate(); err != nil {
log.Printf("durable: StorageBackend.Write gate-rejected offset=%d: %v", offset, err)
return 0, err
}
if len(p) == 0 {
+15
View File
@@ -7,6 +7,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"log"
"github.com/seaweedfs/seaweed-block/core/frontend"
)
@@ -197,7 +198,9 @@ func (h *SCSIHandler) HandleCommand(ctx context.Context, cdb [16]byte, dataOut [
// rule §3.6 (error-faithful Sync wire) makes data-integrity
// hazards visible to the host.
case ScsiSyncCache10, ScsiSyncCache16:
log.Printf("iscsi: SCSI SYNCHRONIZE_CACHE handler entry opcode=0x%02x", cdb[0])
if err := h.backend.Sync(ctx); err != nil {
log.Printf("iscsi: SCSI SYNCHRONIZE_CACHE backend.Sync FAILED: %v", err)
return SCSIResult{
Status: StatusCheckCondition,
SenseKey: SenseMediumError,
@@ -206,6 +209,7 @@ func (h *SCSIHandler) HandleCommand(ctx context.Context, cdb [16]byte, dataOut [
Reason: fmt.Sprintf("SYNC_CACHE: backend sync: %v", err),
}
}
log.Printf("iscsi: SCSI SYNCHRONIZE_CACHE backend.Sync ok")
return SCSIResult{Status: StatusGood}
// Batch 10.5: 16-byte data variants (64-bit LBA).
case ScsiRead16:
@@ -258,21 +262,32 @@ func (h *SCSIHandler) doRead(ctx context.Context, lba uint64, transferLen uint32
}
func (h *SCSIHandler) doWrite(ctx context.Context, lba uint64, transferLen uint32, dataOut []byte) SCSIResult {
// G5-5 instrumentation: log every SCSI WRITE arrival at the
// handler. If this line doesn't fire when the kernel initiator
// writes, the iSCSI session/login layer is rejecting the
// command before it reaches the SCSI handler.
log.Printf("iscsi: SCSI WRITE handler lba=%d transferLen=%d dataOut=%d", lba, transferLen, len(dataOut))
if transferLen == 0 {
return SCSIResult{Status: StatusGood}
}
totalBlocks := h.volumeSize / uint64(h.blockSize)
if lba >= totalBlocks || lba+uint64(transferLen) > totalBlocks {
log.Printf("iscsi: SCSI WRITE rejected (LBA out of range): lba=%d transferLen=%d totalBlocks=%d",
lba, transferLen, totalBlocks)
return illegalRequest(ASCLBAOutOfRange, 0x00, "write LBA out of range")
}
expectedBytes := int(transferLen) * int(h.blockSize)
if len(dataOut) < expectedBytes {
log.Printf("iscsi: SCSI WRITE rejected (short dataOut): expected=%d got=%d",
expectedBytes, len(dataOut))
return illegalRequest(ASCInvalidFieldInCDB, 0x00, "dataOut shorter than expected")
}
_, err := h.backend.Write(ctx, int64(lba)*int64(h.blockSize), dataOut[:expectedBytes])
if err != nil {
log.Printf("iscsi: SCSI WRITE backend.Write FAILED lba=%d: %v", lba, err)
return mapBackendError(err, "write")
}
log.Printf("iscsi: SCSI WRITE backend.Write ok lba=%d", lba)
return SCSIResult{Status: StatusGood}
}