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

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