Blame SOURCES/kvm-QIOChannelSocket-Fix-zero-copy-flush-returning-code-.patch

4841a6
From 905cc8032fc63619efb3f0a8c9754b7190bcc43a Mon Sep 17 00:00:00 2001
719b13
From: Leonardo Bras <leobras@redhat.com>
719b13
Date: Mon, 11 Jul 2022 18:11:11 -0300
4841a6
Subject: [PATCH 3/9] QIOChannelSocket: Fix zero-copy flush returning code 1
719b13
 when nothing sent
719b13
MIME-Version: 1.0
719b13
Content-Type: text/plain; charset=UTF-8
719b13
Content-Transfer-Encoding: 8bit
719b13
719b13
RH-Author: Leonardo Brás <leobras@redhat.com>
4841a6
RH-MergeRequest: 201: Zero-copy-send fixes + improvements
4841a6
RH-Commit: [3/8] 1ad707702fa26cd4d0fa1870c21f5f26ae93ff97
4841a6
RH-Bugzilla: 2110203
719b13
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
RH-Acked-by: Peter Xu <peterx@redhat.com>
4841a6
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
719b13
719b13
If flush is called when no buffer was sent with MSG_ZEROCOPY, it currently
719b13
returns 1. This return code should be used only when Linux fails to use
719b13
MSG_ZEROCOPY on a lot of sendmsg().
719b13
719b13
Fix this by returning early from flush if no sendmsg(...,MSG_ZEROCOPY)
719b13
was attempted.
719b13
719b13
Fixes: 2bc58ffc2926 ("QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX")
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
719b13
Acked-by: Daniel P. Berrangé <berrange@redhat.com>
719b13
Reviewed-by: Juan Quintela <quintela@redhat.com>
719b13
Reviewed-by: Peter Xu <peterx@redhat.com>
719b13
Message-Id: <20220711211112.18951-2-leobras@redhat.com>
719b13
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
(cherry picked from commit 927f93e099c4f9184e60a1bc61624ac2d04d0223)
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
---
719b13
 io/channel-socket.c | 8 +++++++-
719b13
 1 file changed, 7 insertions(+), 1 deletion(-)
719b13
719b13
diff --git a/io/channel-socket.c b/io/channel-socket.c
719b13
index df858da924..cf0d67c51b 100644
719b13
--- a/io/channel-socket.c
719b13
+++ b/io/channel-socket.c
719b13
@@ -717,12 +717,18 @@ static int qio_channel_socket_flush(QIOChannel *ioc,
719b13
     struct cmsghdr *cm;
719b13
     char control[CMSG_SPACE(sizeof(*serr))];
719b13
     int received;
719b13
-    int ret = 1;
719b13
+    int ret;
719b13
+
719b13
+    if (sioc->zero_copy_queued == sioc->zero_copy_sent) {
719b13
+        return 0;
719b13
+    }
719b13
 
719b13
     msg.msg_control = control;
719b13
     msg.msg_controllen = sizeof(control);
719b13
     memset(control, 0, sizeof(control));
719b13
 
719b13
+    ret = 1;
719b13
+
719b13
     while (sioc->zero_copy_sent < sioc->zero_copy_queued) {
719b13
         received = recvmsg(sioc->fd, &msg, MSG_ERRQUEUE);
719b13
         if (received < 0) {
719b13
-- 
4841a6
2.31.1
719b13