assert(ret == 0);
}
+static void vq_send_element(struct fv_QueueInfo *qi, VuVirtqElement *elem,
+ ssize_t len)
+{
+ struct fuse_session *se = qi->virtio_dev->se;
+ VuDev *dev = &se->virtio_dev->dev;
+ VuVirtq *q = vu_get_queue(dev, qi->qidx);
+
+ vu_dispatch_rdlock(qi->virtio_dev);
+ pthread_mutex_lock(&qi->vq_lock);
+ vu_queue_push(dev, q, elem, len);
+ vu_queue_notify(dev, q);
+ pthread_mutex_unlock(&qi->vq_lock);
+ vu_dispatch_unlock(qi->virtio_dev);
+}
+
/*
* Called back by ll whenever it wants to send a reply/message back
* The 1st element of the iov starts with the fuse_out_header
{
FVRequest *req = container_of(ch, FVRequest, ch);
struct fv_QueueInfo *qi = ch->qi;
- VuDev *dev = &se->virtio_dev->dev;
- VuVirtq *q = vu_get_queue(dev, qi->qidx);
VuVirtqElement *elem = &req->elem;
int ret = 0;
copy_iov(iov, count, in_sg, in_num, tosend_len);
- vu_dispatch_rdlock(qi->virtio_dev);
- pthread_mutex_lock(&qi->vq_lock);
- vu_queue_push(dev, q, elem, tosend_len);
- vu_queue_notify(dev, q);
- pthread_mutex_unlock(&qi->vq_lock);
- vu_dispatch_unlock(qi->virtio_dev);
-
+ vq_send_element(qi, elem, tosend_len);
req->reply_sent = true;
err:
{
FVRequest *req = container_of(ch, FVRequest, ch);
struct fv_QueueInfo *qi = ch->qi;
- VuDev *dev = &se->virtio_dev->dev;
- VuVirtq *q = vu_get_queue(dev, qi->qidx);
VuVirtqElement *elem = &req->elem;
int ret = 0;
g_autofree struct iovec *in_sg_cpy = NULL;
out_sg->len = tosend_len;
}
- vu_dispatch_rdlock(qi->virtio_dev);
- pthread_mutex_lock(&qi->vq_lock);
- vu_queue_push(dev, q, elem, tosend_len);
- vu_queue_notify(dev, q);
- pthread_mutex_unlock(&qi->vq_lock);
- vu_dispatch_unlock(qi->virtio_dev);
+ vq_send_element(qi, elem, tosend_len);
req->reply_sent = true;
return 0;
}
{
struct fv_QueueInfo *qi = user_data;
struct fuse_session *se = qi->virtio_dev->se;
- struct VuDev *dev = &qi->virtio_dev->dev;
FVRequest *req = data;
VuVirtqElement *elem = &req->elem;
struct fuse_buf fbuf = {};
/* If the request has no reply, still recycle the virtqueue element */
if (!req->reply_sent) {
- struct VuVirtq *q = vu_get_queue(dev, qi->qidx);
-
fuse_log(FUSE_LOG_DEBUG, "%s: elem %d no reply sent\n", __func__,
elem->index);
-
- vu_dispatch_rdlock(qi->virtio_dev);
- pthread_mutex_lock(&qi->vq_lock);
- vu_queue_push(dev, q, elem, 0);
- vu_queue_notify(dev, q);
- pthread_mutex_unlock(&qi->vq_lock);
- vu_dispatch_unlock(qi->virtio_dev);
+ vq_send_element(qi, elem, 0);
}
pthread_mutex_destroy(&req->ch.lock);