Commit 75e8363c authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

nvmf/tcp: Use an spdk_sock_flush instead of an spdk_sock_write



For IC_RESP and C2H_TERM_REQ, use the regular async write path but add
an additional flush. The flush operation reports errors, so we may at
some point attempt to handle busy conditions by blocking. However, for
now this doesn't do that because previously the writev call didn't
either.

Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15213

 (master)

(cherry picked from commit b11407d0)
Change-Id: I4d05e19ac6dd781be7c96005549abdb52511b8c1
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16485


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent ee21fc24
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -951,26 +951,26 @@ _pdu_write_done(struct nvme_tcp_pdu *pdu, int err)
static void
_tcp_write_pdu(struct nvme_tcp_pdu *pdu)
{
	uint32_t mapped_length = 0;
	ssize_t rc;
	int rc;
	uint32_t mapped_length;
	struct spdk_nvmf_tcp_qpair *tqpair = pdu->qpair;

	pdu->sock_req.iovcnt = nvme_tcp_build_iovs(pdu->iov, SPDK_COUNTOF(pdu->iov), pdu,
			       tqpair->host_hdgst_enable, tqpair->host_ddgst_enable,
			       &mapped_length);
			       tqpair->host_hdgst_enable, tqpair->host_ddgst_enable, &mapped_length);
	spdk_sock_writev_async(tqpair->sock, &pdu->sock_req);

	if (pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_RESP ||
	    pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_C2H_TERM_REQ) {
		rc = spdk_sock_writev(tqpair->sock, pdu->iov, pdu->sock_req.iovcnt);
		if (rc == mapped_length) {
		/* Try to force the send immediately. */
		rc = spdk_sock_flush(tqpair->sock);
		if (rc > 0 && (uint32_t)rc == mapped_length) {
			_pdu_write_done(pdu, 0);
		} else {
			SPDK_ERRLOG("Could not write %s to socket: rc=%zd, errno=%d\n",
			SPDK_ERRLOG("Could not write %s to socket: rc=%d, errno=%d\n",
				    pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_RESP ?
				    "IC_RESP" : "TERM_REQ", rc, errno);
			_pdu_write_done(pdu, -1);
			_pdu_write_done(pdu, rc >= 0 ? -EAGAIN : -errno);
		}
	} else {
		spdk_sock_writev_async(tqpair->sock, &pdu->sock_req);
	}
}