4841a6
From c1fd32d93ae42fcf3c1a25f4d56e669f251087d8 Mon Sep 17 00:00:00 2001
719b13
From: Leonardo Bras <leobras@redhat.com>
719b13
Date: Mon, 20 Jun 2022 02:39:43 -0300
4841a6
Subject: [PATCH 25/37] QIOChannelSocket: Fix zero-copy send so socket flush
719b13
 works
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: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
4841a6
RH-Commit: [25/26] 3ede94f3269e21c3ace073ed1a6f24696315bcbb
4841a6
RH-Bugzilla: 2072049
719b13
RH-Acked-by: Peter Xu <peterx@redhat.com>
4841a6
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
4841a6
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
719b13
Somewhere between v6 and v7 the of the zero-copy-send patchset a crucial
719b13
part of the flushing mechanism got missing: incrementing zero_copy_queued.
719b13
719b13
Without that, the flushing interface becomes a no-op, and there is no
719b13
guarantee the buffer is really sent.
719b13
719b13
This can go as bad as causing a corruption in RAM during migration.
719b13
719b13
Fixes: 2bc58ffc2926 ("QIOChannelSocket: Implement io_writev zero copy flag & io_flush for CONFIG_LINUX")
719b13
Reported-by: 徐闯 <xuchuangxclwt@bytedance.com>
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
719b13
Reviewed-by: Peter Xu <peterx@redhat.com>
719b13
Reviewed-by: Juan Quintela <quintela@redhat.com>
719b13
Signed-off-by: Juan Quintela <quintela@redhat.com>
719b13
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
(cherry picked from commit 4f5a09714c983a3471fd12e3c7f3196e95c650c1)
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
---
719b13
 io/channel-socket.c | 5 +++++
719b13
 1 file changed, 5 insertions(+)
719b13
719b13
diff --git a/io/channel-socket.c b/io/channel-socket.c
719b13
index 7d37b39de7..df858da924 100644
719b13
--- a/io/channel-socket.c
719b13
+++ b/io/channel-socket.c
719b13
@@ -612,6 +612,11 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
719b13
                          "Unable to write to socket");
719b13
         return -1;
719b13
     }
719b13
+
719b13
+    if (flags & QIO_CHANNEL_WRITE_FLAG_ZERO_COPY) {
719b13
+        sioc->zero_copy_queued++;
719b13
+    }
719b13
+
719b13
     return ret;
719b13
 }
719b13
 #else /* WIN32 */
719b13
-- 
719b13
2.35.3
719b13