wzcheng99 903417846b T2 checkpoint 2: iSCSI SCSI handler + L0.i1/i2/i3/i4 green
core/frontend/iscsi/scsi.go
  SCSIHandler adapting frontend.Backend to SCSI CDB dispatch.
  Minimal opcode set for T2 L0: TEST_UNIT_READY, REQUEST_SENSE,
  INQUIRY (standard, non-VPD), READ_CAPACITY(10), READ(10),
  WRITE(10), REPORT_LUNS. Every READ/WRITE routes through
  frontend.Backend.Read / .Write — the per-op lineage fence
  fires exactly once per SCSI command.

  mapBackendError maps frontend error values to SCSI status/sense:
    ErrStalePrimary  -> CHECK CONDITION + NOT READY +
                        ASC 0x04/ASCQ 0x0A (ALUA asymmetric access
                        state transition — matches lineage-move
                        semantics, distinct from generic not-ready)
    ErrBackendClosed -> CHECK CONDITION + NOT READY +
                        ASC 0x04/ASCQ 0x00 (cause not reportable)
  Distinct ASCQ so operators can tell stale-lineage and
  closed/faulted apart in logs.

  LBA-range and short-dataOut validation happens BEFORE the
  backend call (fail closed). Zero-length transfer is a valid
  no-op and does not touch the backend.

core/frontend/iscsi/errors.go
  ASCStaleLineage/ASCQStaleLineage now pinned to SPC-5's
  "asymmetric access state transition" pair (0x04/0x0A) for the
  reason above. Single source of truth for the stale-lineage
  wire mapping.

core/frontend/iscsi/scsi_test.go (QA-owned, test-spec §4)
  T2.L0.i1 TestT2ISCSI_CommandReadWrite_UsesFrontendBackend:
    WRITE(10) then READ(10) route through recording backend;
    exact offset, exact data, single invocation each.
  T2.L0.i2 TestT2ISCSI_StaleWrite_ReturnsCheckCondition:
    stale WRITE -> non-Good, CHECK CONDITION, NotReady,
    stale-lineage ASC; never silently ACKs success.
  T2.L0.i3 TestT2ISCSI_StaleRead_ReturnsCheckCondition:
    stale READ -> non-Good, zero data bytes, CHECK CONDITION;
    never leaks stale bytes to initiator.
  T2.L0.i4 TestT2ISCSI_InvalidInput_FailsClosed:
    table-driven — LBA past end, LBA overflow window, short
    dataOut. Each fails at the handler, backend never invoked.
    Zero-length transfer verified as valid no-op.

  Plus sw-added regressions:
    - TestT2ISCSI_BackendClosed_MapsToNotReady pins the
      stale-vs-closed ASCQ distinction so future refactors can't
      collapse the two fail modes.
    - TestT2ISCSI_MetadataCommands_SuccessForT2Subset covers
      TUR/INQUIRY/READ CAPACITY/REPORT LUNS/REQUEST SENSE happy
      path (initiator handshake won't blow up once PDU framing
      lands).
    - TestT2ISCSI_UnknownOpcode_ReturnsIllegalRequest ensures
      unknown CDBs fail-closed and never reach the backend.

Scope: this checkpoint delivers handler-LEVEL coverage of the
four L0 T2.i* tests. Session-LEVEL API (Login/Session, wire
PDUs, TCP target) lands with PDU framing in the next checkpoint
— at which point L1 component tests (in-process target +
Provider) can run against real Go initiator code.

Tests green (no regressions):
  core/frontend:         T1 suite unchanged (18s incl. L2)
  core/frontend/iscsi:   16 tests (errors 4 + guard 1 + scsi 11)
  core/frontend/memback: 6
  core/frontend/testback: 4
  core/host/volume:      prior volume suite
2026-04-21 17:23:49 -07:00
Languages
Go 84.7%
Rust 7.7%
Shell 2.7%
templ 1.5%
Java 1%
Other 2.1%