nvmf/tcp: Minimize the places where the tqpair state changes
All transitions to the EXITING state go through the disconnect function now Change-Id: Ia55816351b2998bfef26130b6ffdc4a1010567a1 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470533 Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ziye Yang <ziye.yang@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
04a4aab2e0
commit
053fa66b10
@ -758,14 +758,22 @@ spdk_nvmf_tcp_stop_listen(struct spdk_nvmf_transport *transport,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void spdk_nvmf_tcp_qpair_set_recv_state(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
enum nvme_tcp_pdu_recv_state state);
|
||||
|
||||
static void
|
||||
spdk_nvmf_tcp_qpair_disconnect(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
{
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "Disconnecting qpair %p\n", tqpair);
|
||||
|
||||
tqpair->state = NVME_TCP_QPAIR_STATE_EXITED;
|
||||
spdk_poller_unregister(&tqpair->timeout_poller);
|
||||
spdk_nvmf_qpair_disconnect(&tqpair->qpair, NULL, NULL);
|
||||
if (tqpair->state <= NVME_TCP_QPAIR_STATE_RUNNING) {
|
||||
tqpair->state = NVME_TCP_QPAIR_STATE_EXITING;
|
||||
spdk_nvmf_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||
spdk_poller_unregister(&tqpair->timeout_poller);
|
||||
|
||||
/* This will end up calling spdk_nvmf_tcp_close_qpair */
|
||||
spdk_nvmf_qpair_disconnect(&tqpair->qpair, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1279,8 +1287,7 @@ spdk_nvmf_tcp_capsule_cmd_hdr_handle(struct spdk_nvmf_tcp_transport *ttransport,
|
||||
|
||||
/* The host sent more commands than the maximum queue depth. */
|
||||
SPDK_ERRLOG("Cannot allocate tcp_req on tqpair=%p\n", tqpair);
|
||||
tqpair->state = NVME_TCP_QPAIR_STATE_EXITING;
|
||||
spdk_nvmf_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||
spdk_nvmf_tcp_qpair_disconnect(tqpair);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2503,11 +2510,8 @@ spdk_nvmf_tcp_sock_cb(void *arg, struct spdk_sock_group *group, struct spdk_sock
|
||||
assert(tqpair != NULL);
|
||||
rc = spdk_nvmf_tcp_sock_process(tqpair);
|
||||
|
||||
/* check the following two factors:
|
||||
* rc: The socket is closed
|
||||
* State of tqpair: The tqpair is in EXITING state due to internal error
|
||||
*/
|
||||
if ((rc < 0) || (tqpair->state == NVME_TCP_QPAIR_STATE_EXITING)) {
|
||||
/* If there was a new socket error, disconnect */
|
||||
if (rc < 0) {
|
||||
spdk_nvmf_tcp_qpair_disconnect(tqpair);
|
||||
}
|
||||
}
|
||||
@ -2598,9 +2602,13 @@ spdk_nvmf_tcp_req_complete(struct spdk_nvmf_request *req)
|
||||
static void
|
||||
spdk_nvmf_tcp_close_qpair(struct spdk_nvmf_qpair *qpair)
|
||||
{
|
||||
struct spdk_nvmf_tcp_qpair *tqpair;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "Qpair: %p\n", qpair);
|
||||
|
||||
spdk_nvmf_tcp_qpair_destroy(SPDK_CONTAINEROF(qpair, struct spdk_nvmf_tcp_qpair, qpair));
|
||||
tqpair = SPDK_CONTAINEROF(qpair, struct spdk_nvmf_tcp_qpair, qpair);
|
||||
tqpair->state = NVME_TCP_QPAIR_STATE_EXITED;
|
||||
spdk_nvmf_tcp_qpair_destroy(tqpair);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
x
Reference in New Issue
Block a user