From b12419a231fc00ca521c32040495a8bb2f66c2cc Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Tue, 31 Jan 2023 14:54:43 +0100 Subject: [PATCH] tcp: don't abort requests waiting for R2T ACK It is possible for requests waiting for R2T ACK to receive H2C PDU before receiving the ACK. Therefore, the following sequence: 1. Host sends a write request to the target. 2. Target sends R2T PDU to the host and sets request's state to AWAITING_R2T_ACK. 3. Host sends H2C PDU to the target, but it doesn't reach the target yet. 3. Host sends an abort command to abort that request. Request's state is changed to READY_TO_COMPLETE. 4. Target receives the H2C PDU, sees that request's state is READY_TO_COMPLETE, which is unexpected, and terminates the connection. will cause the target to terminate the connection, which is obviously incorrect. So, to avoid that, we can treat AWAITING_R2T_ACK state in the same way as TRANSFERRING_HOST_TO_CONTROLLER and register a poller waiting for the state to be changed. Fixes #2789. Signed-off-by: Konrad Sztyber Change-Id: Idddc627050000b74663dba397dc14d10aa0e284f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16641 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk --- lib/nvmf/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index 4aa6210ac..16d988848 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -3314,11 +3314,11 @@ _nvmf_tcp_qpair_abort_request(void *ctx) nvmf_tcp_req_process(ttransport, tcp_req_to_abort); break; - case TCP_REQUEST_STATE_AWAITING_R2T_ACK: case TCP_REQUEST_STATE_ZCOPY_START_COMPLETED: nvmf_tcp_req_set_abort_status(req, tcp_req_to_abort); break; + case TCP_REQUEST_STATE_AWAITING_R2T_ACK: case TCP_REQUEST_STATE_TRANSFERRING_HOST_TO_CONTROLLER: if (spdk_get_ticks() < req->timeout_tsc) { req->poller = SPDK_POLLER_REGISTER(_nvmf_tcp_qpair_abort_request, req, 0);