nvme/tcp: prevent recursive calls to connect_qpair_poll()

This will allow us to call `connect_qpair_poll()` from
`process_completions()`.  Otherwise, `nvme_fabric_qpair_connect_poll()`
which calls `process_completions()` might create a loop, which can cause
issues with `nvme_completion_poll_status` used for tracking the CONNECT
command by the fabrics code.

Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ibd67bc3e011b238db264394e005b3268624cceef
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8623
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
Konrad Sztyber 2021-07-02 10:17:52 +02:00 committed by Tomasz Zawadzki
parent b49fa72b22
commit 17f99bbb46

View File

@ -95,7 +95,8 @@ struct nvme_tcp_qpair {
uint16_t host_hdgst_enable: 1;
uint16_t host_ddgst_enable: 1;
uint16_t icreq_send_ack: 1;
uint16_t reserved: 13;
uint16_t in_connect_poll: 1;
uint16_t reserved: 12;
} flags;
/** Specifies the maximum number of PDU-Data bytes per H2C Data Transfer PDU */
@ -1931,6 +1932,16 @@ nvme_tcp_ctrlr_connect_qpair_poll(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvm
tqpair = nvme_tcp_qpair(qpair);
/* Prevent this function from being called recursively, as it could lead to issues with
* nvme_fabric_qpair_connect_poll() if the connect response is received in the recursive
* call.
*/
if (tqpair->flags.in_connect_poll) {
return -EAGAIN;
}
tqpair->flags.in_connect_poll = 1;
switch (tqpair->state) {
case NVME_TCP_QPAIR_STATE_INVALID:
case NVME_TCP_QPAIR_STATE_INITIALIZING:
@ -1966,6 +1977,7 @@ nvme_tcp_ctrlr_connect_qpair_poll(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvm
break;
}
tqpair->flags.in_connect_poll = 0;
return rc;
}