nvme/tcp: Add a timeout for construct connection.
Purpose: To avoid the hang if there is no response from the target. Signed-off-by: Ziye Yang <ziye.yang@intel.com> Change-Id: Ib68a9e4c1a28436af2b2ae65891de04067e3dc7d Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477121 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
d0ff231e36
commit
0e3dbd9a60
@ -52,6 +52,7 @@
|
||||
#include "spdk_internal/nvme_tcp.h"
|
||||
|
||||
#define NVME_TCP_RW_BUFFER_SIZE 131072
|
||||
#define NVME_TCP_TIME_OUT_IN_SECONDS 2
|
||||
|
||||
#define NVME_TCP_HPDA_DEFAULT 0
|
||||
#define NVME_TCP_MAX_R2T_DEFAULT 1
|
||||
@ -1526,6 +1527,8 @@ nvme_tcp_qpair_icreq_send(struct nvme_tcp_qpair *tqpair)
|
||||
{
|
||||
struct spdk_nvme_tcp_ic_req *ic_req;
|
||||
struct nvme_tcp_pdu *pdu;
|
||||
uint64_t icreq_timeout_tsc;
|
||||
int rc;
|
||||
|
||||
pdu = &tqpair->send_pdu;
|
||||
memset(&tqpair->send_pdu, 0, sizeof(tqpair->send_pdu));
|
||||
@ -1543,9 +1546,11 @@ nvme_tcp_qpair_icreq_send(struct nvme_tcp_qpair *tqpair)
|
||||
|
||||
nvme_tcp_qpair_write_pdu(tqpair, pdu, nvme_tcp_send_icreq_complete, tqpair);
|
||||
|
||||
while (tqpair->state == NVME_TCP_QPAIR_STATE_INVALID) {
|
||||
nvme_tcp_qpair_process_completions(&tqpair->qpair, 0);
|
||||
}
|
||||
icreq_timeout_tsc = spdk_get_ticks() + (NVME_TCP_TIME_OUT_IN_SECONDS * spdk_get_ticks_hz());
|
||||
do {
|
||||
rc = nvme_tcp_qpair_process_completions(&tqpair->qpair, 0);
|
||||
} while ((tqpair->state == NVME_TCP_QPAIR_STATE_INVALID) &&
|
||||
(rc == 0) && (spdk_get_ticks() <= icreq_timeout_tsc));
|
||||
|
||||
if (tqpair->state != NVME_TCP_QPAIR_STATE_RUNNING) {
|
||||
SPDK_ERRLOG("Failed to construct the tqpair=%p via correct icresp\n", tqpair);
|
||||
|
Loading…
x
Reference in New Issue
Block a user