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

nvmf/tcp: don't wait until host closes connection



There are several cases where the target should terminate the connection
immediately (e.g. receiving H2CTermReq or host sending mqes+1 requests),
while the only situation in which the target should wait for the host to
do it is after receiving C2HTermReq.

So, a new flag was added that allows for distinguishing between these
two cases.  It ensures that the target actually closes the socket when
necessary, as previously it'd only stop processing new requests, but
would wait until the host terminates the connection.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I8a7ec47f444ef6ad1e69aa20a4a39ecbec48a27c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20448


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 9e509a7d
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -300,6 +300,9 @@ struct spdk_nvmf_tcp_qpair {
	uint16_t				initiator_port;
	uint16_t				target_port;

	/* Wait until the host terminates the connection (e.g. after sending C2HTermReq) */
	bool					wait_terminate;

	/* Timer used to destroy qpair after detecting transport error issue if initiator does
	 *  not close the connection.
	 */
@@ -1654,6 +1657,7 @@ nvmf_tcp_send_c2h_term_req(struct spdk_nvmf_tcp_qpair *tqpair, struct nvme_tcp_p

	/* Contain the header of the wrong received pdu */
	c2h_term_req->common.plen = c2h_term_req->common.hlen + copy_len;
	tqpair->wait_terminate = true;
	nvmf_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_QUIESCING);
	nvmf_tcp_qpair_write_mgmt_pdu(tqpair, nvmf_tcp_send_c2h_term_req_complete, tqpair);
}
@@ -2416,10 +2420,10 @@ nvmf_tcp_sock_process(struct spdk_nvmf_tcp_qpair *tqpair)
			nvmf_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
			break;
		case NVME_TCP_PDU_RECV_STATE_ERROR:
			if (!spdk_sock_is_connected(tqpair->sock)) {
				return NVME_TCP_PDU_FATAL;
			}
			if (spdk_sock_is_connected(tqpair->sock) && tqpair->wait_terminate) {
				return NVME_TCP_PDU_IN_PROGRESS;
			}
			return NVME_TCP_PDU_FATAL;
		default:
			SPDK_ERRLOG("The state(%d) is invalid\n", tqpair->recv_state);
			abort();