Commit d428a790 authored by Krzysztof Goreczny's avatar Krzysztof Goreczny Committed by Jim Harris
Browse files

nvmf/tcp: set pending_flush flag early



Before commit b402dea6 posix_sock_flush() handled zero copy first and
only then performed actual flush. That order mattered as part of the
_sock_check_zcopy() was calling req->cb_fn() in the
spdk_sock_request_complete().
NVMf TCP in one of possible flows has cb_fn set to
nvmf_tcp_pdu_c2h_data_complete which in turn leads to
spdk_sock_writev_async() in the _tcp_write_pdu().
If that happens then there is an outstanding msg in socket list that
requires flush.
Before b402dea6 it was flushed once req->cb_fn() ended so there was no
need to schedule additional flush. Now it is required.
pending_flush flag is still needed though to avoid the storm of flush
requests messages that might overflow the thread messages list.

Change-Id: Icb695a22775d3fbcab949702fe84dd07901acbce
Signed-off-by: default avatarKrzysztof Goreczny <krzysztof.goreczny@dell.com>
Suggested-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26347


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
parent efe7ec16
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1205,14 +1205,15 @@ static void
tcp_sock_flush_cb(void *arg)
{
	struct spdk_nvmf_tcp_qpair *tqpair = arg;
	int rc = spdk_sock_flush(tqpair->sock);
	int rc;

	tqpair->pending_flush = false;
	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);
	}