Commit a2ae7b96 authored by Krzysztof Goreczny's avatar Krzysztof Goreczny Committed by Konrad Sztyber
Browse files

nvmf/tcp: flush async writes in the interrupt mode



Without a flush connection might get stuck.
Make sure that no excess flush requests are queued by setting a flag.

Change-Id: Ieeeaaf4e169f4c011a9ec47119804fe88f19fd8c
Signed-off-by: default avatarKrzysztof Goreczny <krzysztof.goreczny@dell.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24958


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 7f05f6de
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -325,6 +325,7 @@ struct spdk_nvmf_tcp_qpair {
	void					*fini_cb_arg;

	TAILQ_ENTRY(spdk_nvmf_tcp_qpair)	link;
	bool					pending_flush;
};

struct spdk_nvmf_tcp_control_msg {
@@ -1179,6 +1180,23 @@ _pdu_write_done(struct nvme_tcp_pdu *pdu, int err)
	pdu->sock_req.cb_fn(pdu->sock_req.cb_arg, err);
}

static void
tcp_sock_flush_cb(void *arg)
{
	struct spdk_nvmf_tcp_qpair *tqpair = arg;
	int rc = spdk_sock_flush(tqpair->sock);

	if (rc < 0 && errno == EAGAIN) {
		spdk_thread_send_msg(spdk_get_thread(), tcp_sock_flush_cb, tqpair);
		return;
	}

	tqpair->pending_flush = false;
	if (rc < 0) {
		SPDK_ERRLOG("Could not write to socket: rc=%d, errno=%d\n", rc, errno);
	}
}

static void
_tcp_write_pdu(struct nvme_tcp_pdu *pdu)
{
@@ -1202,6 +1220,12 @@ _tcp_write_pdu(struct nvme_tcp_pdu *pdu)
				    "IC_RESP" : "TERM_REQ", rc, errno);
			_pdu_write_done(pdu, rc >= 0 ? -EAGAIN : -errno);
		}
	} else if (spdk_interrupt_mode_is_enabled()) {
		/* Async writes must be flushed */
		if (!tqpair->pending_flush) {
			tqpair->pending_flush = true;
			spdk_thread_send_msg(spdk_get_thread(), tcp_sock_flush_cb, tqpair);
		}
	}
}