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

719b13
From 9995a5367d511f8597e4006841853eb9b5888065 Mon Sep 17 00:00:00 2001
719b13
From: Leonardo Bras <leobras@redhat.com>
719b13
Date: Mon, 11 Jul 2022 18:11:11 -0300
719b13
Subject: [PATCH 29/34] 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>
719b13
RH-MergeRequest: 185: MSG_ZEROCOPY + Multifd @ rhel8.6
719b13
RH-Commit: [29/34] d383ee721a8b57a4c3b70e1307cbf7db9e22d395
719b13
RH-Bugzilla: 2117252
719b13
RH-Acked-by: quintela1 <quintela@redhat.com>
719b13
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
RH-Acked-by: Peter Xu <peterx@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
-- 
719b13
2.35.3
719b13