From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 14 Aug 2019 18:07:38 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20190814170738.GQ2920@work-vm> References: <5D4CC344.7030706@huawei.com> <5D4CC39D.7040001@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5D4CC39D.7040001@huawei.com> Subject: Re: [Virtio-fs] [PATCH v4 1/2] virtiofsd: add definition of fuse_buf_writev() List-Id: Development discussions about virtio-fs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: piaojun Cc: virtio-fs@redhat.com * piaojun (piaojun@huawei.com) wrote: > Define fuse_buf_writev() which use pwritev and writev to improve io > bandwidth. > > Signed-off-by: Jun Piao > Suggested-by: Dr. David Alan Gilbert > Suggested-by: Stefan Hajnoczi Yep, this part looks OK, Reviewed-by: Dr. David Alan Gilbert > --- > contrib/virtiofsd/buffer.c | 31 +++++++++++++++++++++++++++++++ > contrib/virtiofsd/seccomp.c | 2 ++ > 2 files changed, 33 insertions(+) > > diff --git a/contrib/virtiofsd/buffer.c b/contrib/virtiofsd/buffer.c > index 655be137..cec762f 100644 > --- a/contrib/virtiofsd/buffer.c > +++ b/contrib/virtiofsd/buffer.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > size_t fuse_buf_size(const struct fuse_bufvec *bufv) > { > @@ -71,6 +72,36 @@ static ssize_t fuse_buf_write(const struct fuse_buf *dst, size_t dst_off, > return copied; > } > > +static ssize_t fuse_buf_writev(fuse_req_t req, > + struct fuse_buf *out_buf, > + struct fuse_bufvec *in_buf) > +{ > + ssize_t res, i; > + size_t iovcnt = in_buf->count; > + struct iovec * iov; > + int fd = out_buf->fd; > + > + iov = calloc(iovcnt, sizeof(struct iovec)); > + if (!iov) > + return -ENOMEM; > + > + for (i = 0; i < iovcnt; i++) { > + iov[i].iov_base = in_buf->buf[i].mem; > + iov[i].iov_len = in_buf->buf[i].size; > + } > + > + if (out_buf->flags & FUSE_BUF_FD_SEEK) > + res = pwritev(fd, iov, iovcnt, out_buf->pos); > + else > + res = writev(fd, iov, iovcnt); > + > + if (res == -1) > + res = -errno; > + > + free(iov); > + return res; > +} > + > static ssize_t fuse_buf_read(const struct fuse_buf *dst, size_t dst_off, > const struct fuse_buf *src, size_t src_off, > size_t len) > diff --git a/contrib/virtiofsd/seccomp.c b/contrib/virtiofsd/seccomp.c > index 5f1c873..4bba30b 100644 > --- a/contrib/virtiofsd/seccomp.c > +++ b/contrib/virtiofsd/seccomp.c > @@ -60,6 +60,7 @@ static const int syscall_whitelist[] = { > SCMP_SYS(ppoll), > SCMP_SYS(prctl), /* TODO restrict to just PR_SET_NAME? */ > SCMP_SYS(preadv), > + SCMP_SYS(pwritev), > SCMP_SYS(pwrite64), > SCMP_SYS(read), > SCMP_SYS(readlinkat), > @@ -78,6 +79,7 @@ static const int syscall_whitelist[] = { > SCMP_SYS(unlinkat), > SCMP_SYS(utimensat), > SCMP_SYS(write), > + SCMP_SYS(writev), > }; > > /* Syscalls used when --syslog is enabled */ > -- -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK