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