[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 024/104] virtiofsd: Keep track of replies
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH 024/104] virtiofsd: Keep track of replies |
Date: |
Thu, 12 Dec 2019 16:37:44 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
Keep track of whether we sent a reply to a request; this is a bit
paranoid but it means:
a) We should always recycle an element even if there was an error
in the request
b) Never try and send two replies on one queue element
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
tools/virtiofsd/fuse_virtio.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c
index c38268a1d5..c33e0f7e8c 100644
--- a/tools/virtiofsd/fuse_virtio.c
+++ b/tools/virtiofsd/fuse_virtio.c
@@ -44,6 +44,7 @@ struct fv_QueueInfo {
/* The element for the command currently being processed */
VuVirtqElement *qe;
+ bool reply_sent;
};
/*
@@ -178,6 +179,7 @@ int virtio_send_msg(struct fuse_session *se, struct
fuse_chan *ch,
{
VuVirtqElement *elem;
VuVirtq *q;
+ int ret = 0;
assert(count >= 1);
assert(iov[0].iov_len >= sizeof(struct fuse_out_header));
@@ -191,6 +193,7 @@ int virtio_send_msg(struct fuse_session *se, struct
fuse_chan *ch,
assert(out->unique);
/* For virtio we always have ch */
assert(ch);
+ assert(!ch->qi->reply_sent);
elem = ch->qi->qe;
q = &ch->qi->virtio_dev->dev.vq[ch->qi->qidx];
@@ -208,19 +211,23 @@ int virtio_send_msg(struct fuse_session *se, struct
fuse_chan *ch,
if (in_len < sizeof(struct fuse_out_header)) {
fuse_log(FUSE_LOG_ERR, "%s: elem %d too short for out_header\n",
__func__, elem->index);
- return -E2BIG;
+ ret = -E2BIG;
+ goto err;
}
if (in_len < tosend_len) {
fuse_log(FUSE_LOG_ERR, "%s: elem %d too small for data len %zd\n",
__func__, elem->index, tosend_len);
- return -E2BIG;
+ ret = -E2BIG;
+ goto err;
}
copy_iov(iov, count, in_sg, in_num, tosend_len);
vu_queue_push(&se->virtio_dev->dev, q, elem, tosend_len);
vu_queue_notify(&se->virtio_dev->dev, q);
+ ch->qi->reply_sent = true;
- return 0;
+err:
+ return ret;
}
/* Thread function for individual queues, created when a queue is 'started' */
@@ -297,6 +304,9 @@ static void *fv_queue_thread(void *opaque)
break;
}
+ qi->qe = elem;
+ qi->reply_sent = false;
+
if (!fbuf.mem) {
fbuf.mem = malloc(se->bufsize);
assert(fbuf.mem);
@@ -332,6 +342,13 @@ static void *fv_queue_thread(void *opaque)
/* TODO: Add checks for fuse_session_exited */
fuse_session_process_buf_int(se, &fbuf, &ch);
+ if (!qi->reply_sent) {
+ fuse_log(FUSE_LOG_DEBUG, "%s: elem %d no reply sent\n",
+ __func__, elem->index);
+ /* I think we've still got to recycle the element */
+ vu_queue_push(dev, q, elem, 0);
+ vu_queue_notify(dev, q);
+ }
qi->qe = NULL;
free(elem);
elem = NULL;
--
2.23.0
- [PATCH 001/104] virtiofsd: Pull in upstream headers, (continued)
- [PATCH 001/104] virtiofsd: Pull in upstream headers, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 012/104] virtiofsd: Trim out compatibility code, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 019/104] virtiofsd: get/set features callbacks, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 018/104] virtiofsd: Add main virtio loop, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 021/104] virtiofsd: Poll kick_fd for queue, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 020/104] virtiofsd: Start queue threads, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 007/104] virtiofsd: Format imported files to qemu style, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 025/104] virtiofsd: Add Makefile wiring for virtiofsd contrib, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 024/104] virtiofsd: Keep track of replies,
Dr. David Alan Gilbert (git) <=
- [PATCH 026/104] virtiofsd: Fast path for virtio read, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 027/104] virtiofsd: add --fd=FDNUM fd passing option, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 022/104] virtiofsd: Start reading commands from queue, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 023/104] virtiofsd: Send replies to messages, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 030/104] virtiofsd: add --print-capabilities option, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 031/104] virtiofs: Add maintainers entry, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 028/104] virtiofsd: make -f (foreground) the default, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 029/104] virtiofsd: add vhost-user.json file, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 032/104] virtiofsd: passthrough_ll: create new files in caller's context, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 033/104] virtiofsd: passthrough_ll: add lo_map for ino/fh indirection, Dr. David Alan Gilbert (git), 2019/12/12