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