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

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