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 <konrad.sztyber@intel.com>
Change-Id: Idddc627050000b74663dba397dc14d10aa0e284f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16641
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Konrad Sztyber 2023-01-31 14:54:43 +01:00 committed by Tomasz Zawadzki
parent c824f88347
commit b12419a231

View File

@ -3314,11 +3314,11 @@ _nvmf_tcp_qpair_abort_request(void *ctx)
nvmf_tcp_req_process(ttransport, tcp_req_to_abort); nvmf_tcp_req_process(ttransport, tcp_req_to_abort);
break; break;
case TCP_REQUEST_STATE_AWAITING_R2T_ACK:
case TCP_REQUEST_STATE_ZCOPY_START_COMPLETED: case TCP_REQUEST_STATE_ZCOPY_START_COMPLETED:
nvmf_tcp_req_set_abort_status(req, tcp_req_to_abort); nvmf_tcp_req_set_abort_status(req, tcp_req_to_abort);
break; break;
case TCP_REQUEST_STATE_AWAITING_R2T_ACK:
case TCP_REQUEST_STATE_TRANSFERRING_HOST_TO_CONTROLLER: case TCP_REQUEST_STATE_TRANSFERRING_HOST_TO_CONTROLLER:
if (spdk_get_ticks() < req->timeout_tsc) { if (spdk_get_ticks() < req->timeout_tsc) {
req->poller = SPDK_POLLER_REGISTER(_nvmf_tcp_qpair_abort_request, req, 0); req->poller = SPDK_POLLER_REGISTER(_nvmf_tcp_qpair_abort_request, req, 0);