Commit b12419a2 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

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: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Idddc627050000b74663dba397dc14d10aa0e284f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16641


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent c824f883
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);