wzcheng99andClaude Opus 4.7 bd1f798051 T2 Batch 11c BUG-001 revert pragmatic evolution → V2-strict faithful port
Reverts the per-CID pendingWrites + async goroutine-spawn design from
commit 6d2c048. Restores V2's inline collectR2TData + pendingCapsules
+ recvH2CData(+bufferInterleaved) pattern as a strict port of
weed/storage/blockvol/nvme/controller.go.

## Why

6d2c048 passed QA's Go-harness tests but broke real Linux kernel
compatibility on m01. Kernel errored "r2t len 32768 exceeded data len
32768 (28672 sent)" — the kernel NVMe-TCP req state machine assumes
AT MOST ONE R2T OUTSTANDING per session, which V2 guarantees by
blocking rxLoop inside collectR2TData/recvH2CData until the current
Write's data is fully received. The pragmatic evolution emitted N
R2Ts async per N pipelined Cmds, which Linux req-state rejected.

Per feedback_porting_discipline.md + port-model decision §D2: port
means port. The QA Go-client tests that expected all-R2Ts-then-
all-H2CData did not match real kernel behavior and misled the fix
direction. QA is withdrawing and rewriting those tests to match
kernel-realistic wire patterns. See BUG-001 §13 for the full
post-mortem.

## What changes

session.go restored to V2 controller.go shape:
  - rxLoop drains pendingCapsules before reading wire each iteration
  - dispatchFromRx for IO Write (no inline): calls collectR2TData
    INLINE in rxLoop (blocks until H2CData fully received), THEN
    spawns handler goroutine for backend.Write
  - collectR2TData: enqueue R2T + wait r2tDone + recvH2CData
  - recvH2CData: loops reading headers; pduCapsuleCmd → bufferInterleaved
    into pendingCapsules; pduH2CData → accumulate
  - bufferInterleaved: fully reads pipelined Cmd into pendingCapsules

Removed (pragmatic-only):
  - pendingWrites map + pwMu + registerPending/lookupPending/unregisterPending
  - routeH2CData (per-CID dispatch from rxLoop)
  - dispatchIOWrite with pre-data goroutine spawn
  - abortPendingWrites cleanup
  - pendingWrite struct + protocolErr
  - R2T r2tSent channel (reverted to r2tDone)

Retained (independent of concurrency model):
  - BUG-002: handleDisconnect + errDisconnect sentinel
  - BUG-004: queueSize / flowCtlOff parsed from CDW11; advanceSQHD wrap;
             flowCtlOff → SQHD=0xFFFF in writeResponse
  - 11a/11b handler *Request refactor (admin_features, fabric, identify)
  - Everything outside session.go

## Test status

  80 PASS:
    - 7 pre-existing debug tests (chunked R2T, 8-queue concurrent,
      admin-while-IO, mkfs-pattern, chunking shapes, errors-verbatim,
      pipelined-initial)
    - A-tier A11.1/A11.2/A11.3/A11.4 (NGUID determinism, advertised-
      features walk, CNTLID allocator, no-retry)
    - 11b Property/Features/KeepAlive/AER suite
    - Boundary guard, identity enforcement, io/errors
    - ConnectionCloseDrainsInflight (passes incidentally — client
      closes conn mid-stream so inline block doesn't matter)

  2 FAIL (QA-owned, will be rewritten per QA plan):
    - TestT2V2Port_NVMe_IO_Pipelined2WritesSameQueue (2s timeout)
    - TestT2V2Port_NVMe_IO_PipelinedNWritesSameQueue (5 subs, 10s each)
    Both expect "send N cmds, read N R2Ts, then send H2CData" pattern
    which deadlocks V2-strict (and which real Linux kernel does not
    emit). QA withdraws; will replace with paired R2T+data pattern.

## Next steps

  - QA: rewrite the 2 RED tests to match real-kernel sequencing
  - sw: re-run m01 mkfs.ext4 after QA's test rewrite lands to verify
    kernel compat
  - If m01 green: promote ledger row PCDD-NVME-IO-H2CDATA-CHUNKED-R2T-001
    to ACTIVE; BUG-001 → VERIFIED → CLOSED after 24h soak

## References

  sw-block/design/bugs/001_nvme_mkfs_r2t_hang_m01.md §13 (post-mortem)
  V2 source: weed/storage/blockvol/nvme/controller.go (rxLoop/txLoop/
             collectR2TData/recvH2CData/bufferInterleaved/pendingCapsules)
  feedback_porting_discipline.md (second citation of this lesson in
             Phase 15 T2 — first was Batch 10.5 VPD 0x80 Serial)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 14:40:00 -07:00
Languages
Go 84.7%
Rust 7.7%
Shell 2.7%
templ 1.5%
Java 1%
Other 2.1%