yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-use-fuse_buf_writev-to-replace-fuse_buf_wr.patch

ddf19c
From 7bc27a767bc8c78b1bca46bbe5e1d53dcd7173b4 Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Mon, 27 Jan 2020 19:02:18 +0100
ddf19c
Subject: [PATCH 107/116] virtiofsd: use fuse_buf_writev to replace
ddf19c
 fuse_buf_write for better performance
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Message-id: <20200127190227.40942-104-dgilbert@redhat.com>
ddf19c
Patchwork-id: 93558
ddf19c
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 103/112] virtiofsd: use fuse_buf_writev to replace fuse_buf_write for better performance
ddf19c
Bugzilla: 1694164
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
ddf19c
From: piaojun <piaojun@huawei.com>
ddf19c
ddf19c
fuse_buf_writev() only handles the normal write in which src is buffer
ddf19c
and dest is fd. Specially if src buffer represents guest physical
ddf19c
address that can't be mapped by the daemon process, IO must be bounced
ddf19c
back to the VMM to do it by fuse_buf_copy().
ddf19c
ddf19c
Signed-off-by: Jun Piao <piaojun@huawei.com>
ddf19c
Suggested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit c465bba2c90a810f6e71e4f2646b1b4ee4b478de)
ddf19c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/buffer.c | 20 ++++++++++++++++++--
ddf19c
 1 file changed, 18 insertions(+), 2 deletions(-)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/buffer.c b/tools/virtiofsd/buffer.c
ddf19c
index 37befeb..27c1377 100644
ddf19c
--- a/tools/virtiofsd/buffer.c
ddf19c
+++ b/tools/virtiofsd/buffer.c
ddf19c
@@ -34,7 +34,6 @@ size_t fuse_buf_size(const struct fuse_bufvec *bufv)
ddf19c
     return size;
ddf19c
 }
ddf19c
 
ddf19c
-__attribute__((unused))
ddf19c
 static ssize_t fuse_buf_writev(struct fuse_buf *out_buf,
ddf19c
                                struct fuse_bufvec *in_buf)
ddf19c
 {
ddf19c
@@ -262,12 +261,29 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len)
ddf19c
 
ddf19c
 ssize_t fuse_buf_copy(struct fuse_bufvec *dstv, struct fuse_bufvec *srcv)
ddf19c
 {
ddf19c
-    size_t copied = 0;
ddf19c
+    size_t copied = 0, i;
ddf19c
 
ddf19c
     if (dstv == srcv) {
ddf19c
         return fuse_buf_size(dstv);
ddf19c
     }
ddf19c
 
ddf19c
+    /*
ddf19c
+     * use writev to improve bandwidth when all the
ddf19c
+     * src buffers already mapped by the daemon
ddf19c
+     * process
ddf19c
+     */
ddf19c
+    for (i = 0; i < srcv->count; i++) {
ddf19c
+        if (srcv->buf[i].flags & FUSE_BUF_IS_FD) {
ddf19c
+            break;
ddf19c
+        }
ddf19c
+    }
ddf19c
+    if ((i == srcv->count) && (dstv->count == 1) &&
ddf19c
+        (dstv->idx == 0) &&
ddf19c
+        (dstv->buf[0].flags & FUSE_BUF_IS_FD)) {
ddf19c
+        dstv->buf[0].pos += dstv->off;
ddf19c
+        return fuse_buf_writev(&dstv->buf[0], srcv);
ddf19c
+    }
ddf19c
+
ddf19c
     for (;;) {
ddf19c
         const struct fuse_buf *src = fuse_bufvec_current(srcv);
ddf19c
         const struct fuse_buf *dst = fuse_bufvec_current(dstv);
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c