From 48b2ac7a13365b0fe9b7293ffa09c2dbd121d06b Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Thu, 3 Dec 2020 23:59:44 +0800 Subject: [PATCH] sock/posix: fix the zero copy enabling in initiator. When zero copy is enabled in initiator, there could be the case that a socket connection does not belong to a polling group, i.e, the application does not use socket polling group. Then we should actively call _sock_check_zcopy in posix_sock_flush function when zero copy policy is enabled. Signed-off-by: Ziye Yang Change-Id: Idceaa7557eb265daa878db40c922494c3de35ea8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5423 Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Community-CI: Mellanox Build Bot --- module/sock/posix/posix.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/module/sock/posix/posix.c b/module/sock/posix/posix.c index d42a0c1af..24a509cd3 100644 --- a/module/sock/posix/posix.c +++ b/module/sock/posix/posix.c @@ -842,9 +842,17 @@ _sock_flush(struct spdk_sock *sock) } static int -posix_sock_flush(struct spdk_sock *_sock) +posix_sock_flush(struct spdk_sock *sock) { - return _sock_flush(_sock); +#ifdef SPDK_ZEROCOPY + struct spdk_posix_sock *psock = __posix_sock(sock); + + if (psock->zcopy && !TAILQ_EMPTY(&sock->pending_reqs)) { + _sock_check_zcopy(sock); + } +#endif + + return _sock_flush(sock); } static ssize_t