[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 100/108] virtiofsd: use fuse_buf_writev to replace fuse_buf_write
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 100/108] virtiofsd: use fuse_buf_writev to replace fuse_buf_write for better performance |
Date: |
Thu, 23 Jan 2020 16:46:22 +0000 |
From: piaojun <address@hidden>
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 <address@hidden>
Suggested-by: Dr. David Alan Gilbert <address@hidden>
Suggested-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Daniel P. Berrangé <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
tools/virtiofsd/buffer.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/tools/virtiofsd/buffer.c b/tools/virtiofsd/buffer.c
index 37befebac2..27c1377f22 100644
--- a/tools/virtiofsd/buffer.c
+++ b/tools/virtiofsd/buffer.c
@@ -34,7 +34,6 @@ size_t fuse_buf_size(const struct fuse_bufvec *bufv)
return size;
}
-__attribute__((unused))
static ssize_t fuse_buf_writev(struct fuse_buf *out_buf,
struct fuse_bufvec *in_buf)
{
@@ -262,12 +261,29 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv,
size_t len)
ssize_t fuse_buf_copy(struct fuse_bufvec *dstv, struct fuse_bufvec *srcv)
{
- size_t copied = 0;
+ size_t copied = 0, i;
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_IS_FD) {
+ break;
+ }
+ }
+ if ((i == srcv->count) && (dstv->count == 1) &&
+ (dstv->idx == 0) &&
+ (dstv->buf[0].flags & FUSE_BUF_IS_FD)) {
+ dstv->buf[0].pos += dstv->off;
+ return fuse_buf_writev(&dstv->buf[0], srcv);
+ }
+
for (;;) {
const struct fuse_buf *src = fuse_bufvec_current(srcv);
const struct fuse_buf *dst = fuse_bufvec_current(dstv);
--
2.24.1
- [PULL 089/108] virtiofsd: prevent races with lo_dirp_put(), (continued)
- [PULL 089/108] virtiofsd: prevent races with lo_dirp_put(), Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 091/108] libvhost-user: Fix some memtable remap cases, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 092/108] virtiofsd: passthrough_ll: fix refcounting on remove/rename, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 097/108] virtiofsd: Fix data corruption with O_APPEND write in writeback mode, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 096/108] virtiofsd: Reset O_DIRECT flag during file open, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 095/108] virtiofsd: convert more fprintf and perror to use fuse log infra, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 094/108] virtiofsd: do not always set FUSE_FLOCK_LOCKS, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 093/108] virtiofsd: introduce inode refcount to prevent use-after-free, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 098/108] virtiofsd: passthrough_ll: Use cache_readdir for directory open, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 099/108] virtiofsd: add definition of fuse_buf_writev(), Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 100/108] virtiofsd: use fuse_buf_writev to replace fuse_buf_write for better performance,
Dr. David Alan Gilbert (git) <=
- [PULL 105/108] virtiofsd: Convert lo_destroy to take the lo->mutex lock itself, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 102/108] virtiofsd: prevent FUSE_INIT/FUSE_DESTROY races, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 101/108] virtiofsd: process requests in a thread pool, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 106/108] virtiofsd/passthrough_ll: Pass errno to fuse_reply_err(), Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 104/108] virtiofsd: add --thread-pool-size=NUM option, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 108/108] virtiofsd: add some options to the help message, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 103/108] virtiofsd: fix lo_destroy() resource leaks, Dr. David Alan Gilbert (git), 2020/01/23
- [PULL 107/108] virtiofsd: stop all queue threads on exit in virtio_loop(), Dr. David Alan Gilbert (git), 2020/01/23
- Re: [PULL 000/108] virtiofs queue, Dr. David Alan Gilbert, 2020/01/23