From 3b17db6f7417d5396230bfd56a64cae4e1e2a47c Mon Sep 17 00:00:00 2001 From: Jean-Yves VET Date: Fri, 13 Mar 2020 20:02:41 +0100 Subject: [PATCH] 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. --- lib/fuse_lowlevel.c | 14 ++++++-------- 1 file 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 || -- 2.30.2