mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
6d2c04802df1aec42dd44038903c0aa26ecf87d6
Bundles Batch 11b (signed, uncommitted) + BUG-001/002/004 co-fix per
Discovery Bridge approved 2026-04-22. Scope delta vs. port plan §5.3:
session-loop rewrite ~250-300 LOC was classified as Linux-compat polish
at 80 LOC; actual need is a full mechanism port (see port audit).
BUG-001 (primary) — mkfs.ext4 hang on m01 / queue-internal CapsuleCmd
pipelining. Linux kernel ships multiple Write cmds on one IO queue
before any R2T is consumed; V3's serial session loop read cmd-N+1 bytes
while collecting H2CData-N and errored "expected H2CData, got 0x4".
Design:
- serve() splits Phase 1 (sync ICReq/ICResp) from Phase 2 (rxLoop +
txLoop goroutines with respCh between).
- rxLoop is sole reader post-IC. Routes by PDU type:
CapsuleCmd -> parseCapsule + dispatchFromRx
H2CData -> routeH2CData, dispatches bytes to pendingWrite by
CCCID; closes done when buffer full
- txLoop is sole writer post-IC. Drains respCh; handles CapsuleResp,
C2HData+CapsuleResp (Read/Identify), and R2T.
- IO Write path: dispatchIOWrite registers a pendingWrite, enqueues
R2T, spawns handler goroutine that waits on done then calls backend.
- Admin/Fabric handlers run synchronously in rxLoop (unchanged from
V2 shape) but enqueue responses through respCh instead of touching
s.w directly.
Deviation from strict V2 port (documented in session.go top comment):
V2's inline collectR2TData -> recvH2CData + pendingCapsules works for
real Linux kernels (they send H2CData immediately after R2T) but
deadlocks against QA's spec-strict tests where host sends N cmds and
expects N R2Ts before any H2CData. V3 moves H2CData collection out of
rxLoop into per-CID pendingWrites map so R2T emission is async. ~60 LOC
delta vs. strict V2 port. QA sign referred to the RX/TX split concurrency
shape, which this preserves verbatim. The spec-correctness advantage
(async R2T) is a pragmatic evolution, not a reinvention of the per-CID
state machine QA flagged.
BUG-002 — fcDisconnect handler. V3 previously returned Invalid Opcode on
`nvme disconnect`. Now handleDisconnect enqueues a success CapsuleResp
and returns errDisconnect sentinel; serve() maps the sentinel to nil.
BUG-004 — SQHD wrap at queueSize + flowCtlOff. Connect now parses
CDW11 low-16 (SQSIZE zero-based +1) and bit 18 (CATTR bit 2). advanceSQHD
wraps at queueSize; writeResponse reports 0xFFFF when flowCtlOff.
Handler signature migration: handleAdminIdentify / handleSetFeatures /
handleGetFeatures / handleKeepAlive / handleAsyncEventRequest /
handlePropertyGet / handlePropertySet now take *Request and route
through enqueueResponse. AER non-blocking park (QA #1) preserved —
handler returns nil without enqueueing when slot is free.
BUG-003 (KATO from Connect CDW12) and RF-1 (bufpool.go) explicitly
OUT of this commit per Discovery Bridge scope.
Tests:
- TestT2V2Port_NVMe_IO_Pipelined2WritesSameQueue (canonical) RED -> GREEN
- TestT2V2Port_NVMe_IO_PipelinedNWritesSameQueue (N=2,4,8,16,32) RED -> GREEN
- TestT2V2Port_NVMe_IO_ConnectionCloseDrainsInflight RED -> GREEN
- All 7 prior debug tests green
- 11a/11b A-tier + adversarial tests green
- Full nvme regression: ok 31.6s (no perf regression)
References:
sw-block/design/bugs/001_nvme_mkfs_r2t_hang_m01.md (BUG-001)
sw-block/design/bugs/002_nvme_fabric_disconnect_missing.md (BUG-002)
sw-block/design/bugs/004_nvme_sqhd_no_wrap.md (BUG-004)
sw-block/design/v3-phase-15-t2-nvme-port-audit.md (scope justification)
feedback_porting_discipline.md (lesson citation)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%