Blame SOURCES/kvm-multifd-Make-zstd-compression-method-not-use-iovs.patch

719b13
From dc083c2407de0a668573e549b8357f451554e376 Mon Sep 17 00:00:00 2001
719b13
From: Juan Quintela <quintela@redhat.com>
719b13
Date: Wed, 18 May 2022 02:52:23 -0300
719b13
Subject: [PATCH 08/34] multifd: Make zstd compression method not use iovs
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: [8/34] 953059f89f3b79f4c515c16877052522c3104753
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
Signed-off-by: Juan Quintela <quintela@redhat.com>
719b13
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
(cherry picked from commit f5ff548774c22b34a0c0e2fef85f1be11160d774)
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
---
719b13
 migration/multifd-zstd.c | 20 ++++++++++----------
719b13
 1 file changed, 10 insertions(+), 10 deletions(-)
719b13
719b13
diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c
719b13
index f0d1105792..d9ed42622b 100644
719b13
--- a/migration/multifd-zstd.c
719b13
+++ b/migration/multifd-zstd.c
719b13
@@ -13,6 +13,7 @@
719b13
 #include "qemu/osdep.h"
719b13
 #include <zstd.h>
719b13
 #include "qemu/rcu.h"
719b13
+#include "exec/ramblock.h"
719b13
 #include "exec/target_page.h"
719b13
 #include "qapi/error.h"
719b13
 #include "migration.h"
719b13
@@ -113,8 +114,8 @@ static void zstd_send_cleanup(MultiFDSendParams *p, Error **errp)
719b13
  */
719b13
 static int zstd_send_prepare(MultiFDSendParams *p, Error **errp)
719b13
 {
719b13
-    struct iovec *iov = p->pages->iov;
719b13
     struct zstd_data *z = p->data;
719b13
+    size_t page_size = qemu_target_page_size();
719b13
     int ret;
719b13
     uint32_t i;
719b13
 
719b13
@@ -128,8 +129,8 @@ static int zstd_send_prepare(MultiFDSendParams *p, Error **errp)
719b13
         if (i == p->pages->num - 1) {
719b13
             flush = ZSTD_e_flush;
719b13
         }
719b13
-        z->in.src = iov[i].iov_base;
719b13
-        z->in.size = iov[i].iov_len;
719b13
+        z->in.src = p->pages->block->host + p->pages->offset[i];
719b13
+        z->in.size = page_size;
719b13
         z->in.pos = 0;
719b13
 
719b13
         /*
719b13
@@ -261,7 +262,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
 {
719b13
     uint32_t in_size = p->next_packet_size;
719b13
     uint32_t out_size = 0;
719b13
-    uint32_t expected_size = p->pages->num * qemu_target_page_size();
719b13
+    size_t page_size = qemu_target_page_size();
719b13
+    uint32_t expected_size = p->pages->num * page_size;
719b13
     uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK;
719b13
     struct zstd_data *z = p->data;
719b13
     int ret;
719b13
@@ -283,10 +285,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
     z->in.pos = 0;
719b13
 
719b13
     for (i = 0; i < p->pages->num; i++) {
719b13
-        struct iovec *iov = &p->pages->iov[i];
719b13
-
719b13
-        z->out.dst = iov->iov_base;
719b13
-        z->out.size = iov->iov_len;
719b13
+        z->out.dst = p->pages->block->host + p->pages->offset[i];
719b13
+        z->out.size = page_size;
719b13
         z->out.pos = 0;
719b13
 
719b13
         /*
719b13
@@ -300,8 +300,8 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
         do {
719b13
             ret = ZSTD_decompressStream(z->zds, &z->out, &z->in);
719b13
         } while (ret > 0 && (z->in.size - z->in.pos > 0)
719b13
-                         && (z->out.pos < iov->iov_len));
719b13
-        if (ret > 0 && (z->out.pos < iov->iov_len)) {
719b13
+                         && (z->out.pos < page_size));
719b13
+        if (ret > 0 && (z->out.pos < page_size)) {
719b13
             error_setg(errp, "multifd %d: decompressStream buffer too small",
719b13
                        p->id);
719b13
             return -1;
719b13
-- 
719b13
2.35.3
719b13