From mboxrd@z Thu Jan 1 00:00:00 1970 References: <5D4BBDB7.2000005@huawei.com> <5D4BBDFF.6060106@huawei.com> From: piaojun Message-ID: <5D4BBE9A.8020103@huawei.com> Date: Thu, 8 Aug 2019 14:18:02 +0800 MIME-Version: 1.0 In-Reply-To: <5D4BBDFF.6060106@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Virtio-fs] [PATCH v3 2/2] virtiofsd: use fuse_buf_writev to replace fuse_buf_write for better performance List-Id: Development discussions about virtio-fs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: virtio-fs@redhat.com fuse_buf_writev() only handles the normal write in which src is buffer and dest is fd. Specially if src buffer represents guest physical address that can't be mapped by the daemon process, IO must be bounced back to the VMM to do it by fuse_buf_copy(). Signed-off-by: Jun Piao Suggested-by: Dr. David Alan Gilbert Suggested-by: Stefan Hajnoczi --- contrib/virtiofsd/buffer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/contrib/virtiofsd/buffer.c b/contrib/virtiofsd/buffer.c index 3920cbf..f09d43c 100644 --- a/contrib/virtiofsd/buffer.c +++ b/contrib/virtiofsd/buffer.c @@ -324,11 +324,22 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len) ssize_t fuse_buf_copy(fuse_req_t req, struct fuse_bufvec *dstv, struct fuse_bufvec *srcv, enum fuse_buf_copy_flags flags) { + size_t i; size_t copied = 0; if (dstv == srcv) return fuse_buf_size(dstv); + /* use writev to improve bandwidth when all the + * src buffers already mapped by the daemon + * process */ + for (i = 0; i < srcv->count; i++) { + if (srcv->buf[i].flags & FUSE_BUF_PHYS_ADDR) + break; + } + if (i == srcv->count) + return fuse_buf_writev(req, dstv, srcv, dstv->buf[0].flags); + for (;;) { const struct fuse_buf *src = fuse_bufvec_current(srcv); const struct fuse_buf *dst = fuse_bufvec_current(dstv); --