diff options
author | Jean-Yves VET <jyvet@users.noreply.github.com> | 2020-03-13 20:02:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-13 19:02:41 +0000 |
commit | 3b17db6f7417d5396230bfd56a64cae4e1e2a47c (patch) | |
tree | dac49bb632084bbdb329eb196aa545210fc0f290 | |
parent | b70c73082d35726f4b8697116a100cb1c9e6874a (diff) | |
download | libfuse-3b17db6f7417d5396230bfd56a64cae4e1e2a47c.tar.gz |
Fix issue preventing using splice with reads (#505)
Context: SPLICE_WRITE is not used with regular buffers
(i.e. when they are not file-descriptor backed buffers).
There is a bug which assumes file descriptors are used.
If the amount of data associated with those FD is lower
than twice the page size, SPLICE_WRITE is not utilized.
With regular buffers the aggregated size was always 0.
Because vmsplice (splice user pages to/from a pipe) is
called before splice in fuse_lowlevel.c, regular buffers
would also work with splice.
This patch prevents to fallback to non-splice enabled
copies when itheir is no FD involved.
-rw-r--r-- | lib/fuse_lowlevel.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index d8112f5..fd1f484 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -650,7 +650,7 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, struct fuse_ll_pipe *llp; int splice_flags; size_t pipesize; - size_t total_fd_size; + size_t total_buf_size; size_t idx; size_t headerlen; struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len); @@ -661,15 +661,13 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch, if (flags & FUSE_BUF_NO_SPLICE) goto fallback; - total_fd_size = 0; + total_buf_size = 0; for (idx = buf->idx; idx < buf->count; idx++) { - if (buf->buf[idx].flags & FUSE_BUF_IS_FD) { - total_fd_size = buf->buf[idx].size; - if (idx == buf->idx) - total_fd_size -= buf->off; - } + total_buf_size = buf->buf[idx].size; + if (idx == buf->idx) + total_buf_size -= buf->off; } - if (total_fd_size < 2 * pagesize) + if (total_buf_size < 2 * pagesize) goto fallback; if (se->conn.proto_minor < 14 || |