[PATCH v2 2/2] nvme-tcp: set up R2T data transfer in the send path
Zhenwen Liang
zhenwenliang at google.com
Tue Nov 24 09:22:53 PST 2026
Thanks, the review is correct. Going through the six points:
Introduced by v2:
- [1] CMD_SENT is set after the command PDU send, when a read or a
command without data may already have been completed and the tag
reused. This can happen with a compliant controller.
- [4] Relaxing the receive-path offset check to "<" lets an R2T with a
larger offset through, so a following CQE can complete the request
while it is still on req_list.
- [6] The new send error path leaves the request on req_list with the
R2T still pending, so it can be sent again and then failed before
error recovery stops the queue.
Already in v7.4-rc4 (misbehaving controller only):
- [2] an R2T between nvme_start_request() and llist_add() in queue_rq,
and an R2T for a write with inline data;
- [3] a duplicate of the final R2T is accepted again, because the final
send does not advance data_sent.
[5], and the part of [2] about an R2T arriving while the command PDU is
still being sent, are also misbehaving-controller cases; v2 changes
their shape but does not make them reachable for a compliant
controller.
I think deferring the R2T setup to the send path was the wrong
direction: it adds per-request state across completion and reuse, and
each round has found new races. Please disregard patch 2/2.
Patch 1/2 (32-bit overflow in the R2T length check) is independent.
The original problem is narrow. With a compliant controller, after
sock_sendmsg() of the last bytes of a non-final R2T, the receive path
can handle the next R2T before nvme_tcp_advance_req() runs. It then
reads a stale data_sent (rejected since 347d50d92e25) and resets
pdu_sent, which the send path advances afterwards (a short H2CData PDU
on stable). We can reproduce both in QEMU with a target that sends one
R2T per 16 KiB.
A smaller fix that leaves request lifetime alone could be: track the
end offset of the R2Ts accepted so far in a field that only the receive
path uses, and check the R2T against that instead of data_sent; and in
the send path, not advance pdu_sent on the send that completes the
H2CData PDU. That keeps today's receive-path setup and error handling.
Thank you again.
More information about the Linux-nvme
mailing list