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