|
|
902636 |
From 9e4320eec5204da851ac95fb7a7e6520c9ccee7d Mon Sep 17 00:00:00 2001
|
|
|
902636 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
902636 |
Date: Mon, 27 Jan 2020 19:01:19 +0100
|
|
|
902636 |
Subject: [PATCH 048/116] virtiofsd: Plumb fuse_bufvec through to do_write_buf
|
|
|
902636 |
MIME-Version: 1.0
|
|
|
902636 |
Content-Type: text/plain; charset=UTF-8
|
|
|
902636 |
Content-Transfer-Encoding: 8bit
|
|
|
902636 |
|
|
|
902636 |
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
902636 |
Message-id: <20200127190227.40942-45-dgilbert@redhat.com>
|
|
|
902636 |
Patchwork-id: 93499
|
|
|
902636 |
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 044/112] virtiofsd: Plumb fuse_bufvec through to do_write_buf
|
|
|
902636 |
Bugzilla: 1694164
|
|
|
902636 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
902636 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
902636 |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
902636 |
|
|
|
902636 |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
902636 |
|
|
|
902636 |
Let fuse_session_process_buf_int take a fuse_bufvec * instead of a
|
|
|
902636 |
fuse_buf; and then through to do_write_buf - where in the best
|
|
|
902636 |
case it can pass that straight through to op.write_buf without copying
|
|
|
902636 |
(other than skipping a header).
|
|
|
902636 |
|
|
|
902636 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
902636 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
902636 |
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
|
|
|
902636 |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
902636 |
(cherry picked from commit 469f9d2fc405b0508e6cf1b4b5bbcadfc82064e5)
|
|
|
902636 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
902636 |
---
|
|
|
902636 |
tools/virtiofsd/fuse_i.h | 2 +-
|
|
|
902636 |
tools/virtiofsd/fuse_lowlevel.c | 61 +++++++++++++++++++++++++++--------------
|
|
|
902636 |
tools/virtiofsd/fuse_virtio.c | 3 +-
|
|
|
902636 |
3 files changed, 44 insertions(+), 22 deletions(-)
|
|
|
902636 |
|
|
|
902636 |
diff --git a/tools/virtiofsd/fuse_i.h b/tools/virtiofsd/fuse_i.h
|
|
|
902636 |
index 45995f3..a20854f 100644
|
|
|
902636 |
--- a/tools/virtiofsd/fuse_i.h
|
|
|
902636 |
+++ b/tools/virtiofsd/fuse_i.h
|
|
|
902636 |
@@ -100,7 +100,7 @@ int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
|
|
|
902636 |
void fuse_free_req(fuse_req_t req);
|
|
|
902636 |
|
|
|
902636 |
void fuse_session_process_buf_int(struct fuse_session *se,
|
|
|
902636 |
- const struct fuse_buf *buf,
|
|
|
902636 |
+ struct fuse_bufvec *bufv,
|
|
|
902636 |
struct fuse_chan *ch);
|
|
|
902636 |
|
|
|
902636 |
|
|
|
902636 |
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
|
|
|
902636 |
index 95f4db8..7e10995 100644
|
|
|
902636 |
--- a/tools/virtiofsd/fuse_lowlevel.c
|
|
|
902636 |
+++ b/tools/virtiofsd/fuse_lowlevel.c
|
|
|
902636 |
@@ -1004,11 +1004,12 @@ static void do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg,
|
|
|
902636 |
- const struct fuse_buf *ibuf)
|
|
|
902636 |
+ struct fuse_bufvec *ibufv)
|
|
|
902636 |
{
|
|
|
902636 |
struct fuse_session *se = req->se;
|
|
|
902636 |
- struct fuse_bufvec bufv = {
|
|
|
902636 |
- .buf[0] = *ibuf,
|
|
|
902636 |
+ struct fuse_bufvec *pbufv = ibufv;
|
|
|
902636 |
+ struct fuse_bufvec tmpbufv = {
|
|
|
902636 |
+ .buf[0] = ibufv->buf[0],
|
|
|
902636 |
.count = 1,
|
|
|
902636 |
};
|
|
|
902636 |
struct fuse_write_in *arg = (struct fuse_write_in *)inarg;
|
|
|
902636 |
@@ -1018,22 +1019,31 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg,
|
|
|
902636 |
fi.fh = arg->fh;
|
|
|
902636 |
fi.writepage = arg->write_flags & FUSE_WRITE_CACHE;
|
|
|
902636 |
|
|
|
902636 |
- fi.lock_owner = arg->lock_owner;
|
|
|
902636 |
- fi.flags = arg->flags;
|
|
|
902636 |
- if (!(bufv.buf[0].flags & FUSE_BUF_IS_FD)) {
|
|
|
902636 |
- bufv.buf[0].mem = PARAM(arg);
|
|
|
902636 |
- }
|
|
|
902636 |
-
|
|
|
902636 |
- bufv.buf[0].size -=
|
|
|
902636 |
- sizeof(struct fuse_in_header) + sizeof(struct fuse_write_in);
|
|
|
902636 |
- if (bufv.buf[0].size < arg->size) {
|
|
|
902636 |
- fuse_log(FUSE_LOG_ERR, "fuse: do_write_buf: buffer size too small\n");
|
|
|
902636 |
- fuse_reply_err(req, EIO);
|
|
|
902636 |
- return;
|
|
|
902636 |
+ if (ibufv->count == 1) {
|
|
|
902636 |
+ fi.lock_owner = arg->lock_owner;
|
|
|
902636 |
+ fi.flags = arg->flags;
|
|
|
902636 |
+ if (!(tmpbufv.buf[0].flags & FUSE_BUF_IS_FD)) {
|
|
|
902636 |
+ tmpbufv.buf[0].mem = PARAM(arg);
|
|
|
902636 |
+ }
|
|
|
902636 |
+ tmpbufv.buf[0].size -=
|
|
|
902636 |
+ sizeof(struct fuse_in_header) + sizeof(struct fuse_write_in);
|
|
|
902636 |
+ if (tmpbufv.buf[0].size < arg->size) {
|
|
|
902636 |
+ fuse_log(FUSE_LOG_ERR,
|
|
|
902636 |
+ "fuse: do_write_buf: buffer size too small\n");
|
|
|
902636 |
+ fuse_reply_err(req, EIO);
|
|
|
902636 |
+ return;
|
|
|
902636 |
+ }
|
|
|
902636 |
+ tmpbufv.buf[0].size = arg->size;
|
|
|
902636 |
+ pbufv = &tmpbufv;
|
|
|
902636 |
+ } else {
|
|
|
902636 |
+ /*
|
|
|
902636 |
+ * Input bufv contains the headers in the first element
|
|
|
902636 |
+ * and the data in the rest, we need to skip that first element
|
|
|
902636 |
+ */
|
|
|
902636 |
+ ibufv->buf[0].size = 0;
|
|
|
902636 |
}
|
|
|
902636 |
- bufv.buf[0].size = arg->size;
|
|
|
902636 |
|
|
|
902636 |
- se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
|
|
|
902636 |
+ se->op.write_buf(req, nodeid, pbufv, arg->offset, &fi);
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
|
|
|
902636 |
@@ -2024,13 +2034,24 @@ static const char *opname(enum fuse_opcode opcode)
|
|
|
902636 |
void fuse_session_process_buf(struct fuse_session *se,
|
|
|
902636 |
const struct fuse_buf *buf)
|
|
|
902636 |
{
|
|
|
902636 |
- fuse_session_process_buf_int(se, buf, NULL);
|
|
|
902636 |
+ struct fuse_bufvec bufv = { .buf[0] = *buf, .count = 1 };
|
|
|
902636 |
+ fuse_session_process_buf_int(se, &bufv, NULL);
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
+/*
|
|
|
902636 |
+ * Restriction:
|
|
|
902636 |
+ * bufv is normally a single entry buffer, except for a write
|
|
|
902636 |
+ * where (if it's in memory) then the bufv may be multiple entries,
|
|
|
902636 |
+ * where the first entry contains all headers and subsequent entries
|
|
|
902636 |
+ * contain data
|
|
|
902636 |
+ * bufv shall not use any offsets etc to make the data anything
|
|
|
902636 |
+ * other than contiguous starting from 0.
|
|
|
902636 |
+ */
|
|
|
902636 |
void fuse_session_process_buf_int(struct fuse_session *se,
|
|
|
902636 |
- const struct fuse_buf *buf,
|
|
|
902636 |
+ struct fuse_bufvec *bufv,
|
|
|
902636 |
struct fuse_chan *ch)
|
|
|
902636 |
{
|
|
|
902636 |
+ const struct fuse_buf *buf = bufv->buf;
|
|
|
902636 |
struct fuse_in_header *in;
|
|
|
902636 |
const void *inarg;
|
|
|
902636 |
struct fuse_req *req;
|
|
|
902636 |
@@ -2108,7 +2129,7 @@ void fuse_session_process_buf_int(struct fuse_session *se,
|
|
|
902636 |
|
|
|
902636 |
inarg = (void *)&in[1];
|
|
|
902636 |
if (in->opcode == FUSE_WRITE && se->op.write_buf) {
|
|
|
902636 |
- do_write_buf(req, in->nodeid, inarg, buf);
|
|
|
902636 |
+ do_write_buf(req, in->nodeid, inarg, bufv);
|
|
|
902636 |
} else {
|
|
|
902636 |
fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
|
|
|
902636 |
}
|
|
|
902636 |
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
|
|
|
902636 |
index 635f877..fd588a4 100644
|
|
|
902636 |
--- a/tools/virtiofsd/fuse_virtio.c
|
|
|
902636 |
+++ b/tools/virtiofsd/fuse_virtio.c
|
|
|
902636 |
@@ -501,7 +501,8 @@ static void *fv_queue_thread(void *opaque)
|
|
|
902636 |
/* TODO! Endianness of header */
|
|
|
902636 |
|
|
|
902636 |
/* TODO: Add checks for fuse_session_exited */
|
|
|
902636 |
- fuse_session_process_buf_int(se, &fbuf, &ch);
|
|
|
902636 |
+ struct fuse_bufvec bufv = { .buf[0] = fbuf, .count = 1 };
|
|
|
902636 |
+ fuse_session_process_buf_int(se, &bufv, &ch);
|
|
|
902636 |
|
|
|
902636 |
if (!qi->reply_sent) {
|
|
|
902636 |
fuse_log(FUSE_LOG_DEBUG, "%s: elem %d no reply sent\n",
|
|
|
902636 |
--
|
|
|
902636 |
1.8.3.1
|
|
|
902636 |
|