From: Stefan Hajnoczi <stefanha@gmail.com>
To: Vitaly Mayatskikh <v.mayatskih@gmail.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] Add vhost_blk driver
Date: Tue, 6 Nov 2018 16:03:16 +0000 [thread overview]
Message-ID: <20181106160316.GC31579@stefanha-x1.localdomain> (raw)
In-Reply-To: <20181102182123.29420-2-v.mayatskih@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3004 bytes --]
On Fri, Nov 02, 2018 at 06:21:23PM +0000, Vitaly Mayatskikh wrote:
> This driver accelerates host side of virtio-blk.
Did you look at vhost-user-blk? It does things slightly differently:
more of the virtio-blk device model is handled by the vhost-user device
(e.g. config space). That might be necessary to implement
virtio_blk_config.writeback properly.
> +#define VHOST_BLK_SET_BACKEND _IOW(VHOST_VIRTIO, 0x50, int)
Needs to be in the uapi header so userspace can use it.
> +
> +enum {
> + VHOST_BLK_VQ_MAX = 16,
> + VHOST_BLK_VQ_MAX_REQS = 128,
> +};
These limits seem arbitrary and probably too low.
> +
> +struct vhost_blk_req {
> + struct llist_node list;
> + int index;
> + struct vhost_blk_queue *q;
> + struct virtio_blk_outhdr hdr;
> + struct iovec *out_iov;
> + struct iovec *in_iov;
> + u8 out_num;
> + u8 in_num;
> + long len;
> + struct kiocb iocb;
> + struct iov_iter i;
> + int res;
> + void __user *status;
> +};
> +
> +struct vhost_blk_queue {
> + int index;
> + struct vhost_blk *blk;
> + struct vhost_virtqueue vq;
> + struct vhost_work w;
> + struct llist_head wl;
What is this? Please use clear names and comments. :)
> +static int vhost_blk_req_handle(struct vhost_blk_req *req)
> +{
> + struct vhost_blk *blk = req->q->blk;
> + struct vhost_virtqueue *vq = &req->q->vq;
> + int type = le32_to_cpu(req->hdr.type);
> + int ret;
> + u8 status;
> +
> + if ((type == VIRTIO_BLK_T_IN) || (type == VIRTIO_BLK_T_OUT)) {
> + bool write = (type == VIRTIO_BLK_T_OUT);
> + int nr_seg = (write ? req->out_num : req->in_num) - 1;
> + unsigned long sector = le64_to_cpu(req->hdr.sector);
Using little-endian instead of the virtio types means that only VIRTIO
1.0 modern devices are supported (older devices may not be
little-endian!). In that case you'd need to put the VIRTIO_1 feature
bit into the features mask.
> + req = &q->req[head];
> + req->index = head;
> + req->out_num = out;
> + req->in_num = in;
> + req->out_iov = &vq->iov[1];
> + req->in_iov = &vq->iov[out];
> + req->status = vq->iov[out + in - 1].iov_base;
The VIRTIO spec explicitly requires that devices support arbitrary
descriptor layouts, so you cannot assume a particular iov[] layout.
> +static long vhost_blk_ioctl(struct file *f, unsigned int ioctl,
> + unsigned long arg)
> +{
> + struct vhost_blk *blk = f->private_data;
> + void __user *argp = (void __user *)arg;
> + int fd;
> + u64 __user *featurep = argp;
> + u64 features;
> + long ret;
> + struct vhost_vring_state s;
> +
> + switch (ioctl) {
> + case VHOST_SET_MEM_TABLE:
> + vhost_blk_stop(blk);
> + ret = vhost_blk_pass_ioctl(blk, ioctl, argp);
> + break;
Why is this necessary? Existing vhost devices pass the ioctl through
without an explicit case for it.
> + case VHOST_SET_VRING_NUM:
> + if (copy_from_user(&s, argp, sizeof(s)))
> + return -EFAULT;
> + ret = vhost_blk_pass_ioctl(blk, ioctl, argp);
> + if (!ret)
> + blk->num_queues = s.index + 1;
Where is this input checked against ARRAY_SIZE(blk->queue)?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2018-11-06 16:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-02 18:21 [PATCH 0/1] vhost: add vhost_blk driver Vitaly Mayatskikh
2018-11-02 18:21 ` [PATCH 1/1] Add " Vitaly Mayatskikh
2018-11-02 18:36 ` Michael S. Tsirkin
2018-11-02 19:24 ` Vitaly Mayatskih
2018-11-02 20:38 ` Michael S. Tsirkin
2018-11-03 2:50 ` kbuild test robot
2018-11-06 16:03 ` Stefan Hajnoczi [this message]
2018-11-06 19:47 ` Vitaly Mayatskih
2018-11-02 18:26 ` [PATCH 0/1] vhost: add " Michael S. Tsirkin
2018-11-02 18:31 ` Vitaly Mayatskih
2018-11-05 14:02 ` Christian Borntraeger
2018-11-05 14:21 ` Vitaly Mayatskih
2018-11-06 15:40 ` Stefan Hajnoczi
2018-11-06 18:46 ` Denis Lunev
2018-11-06 20:08 ` Vitaly Mayatskih
2018-11-04 11:57 ` Maxim Levitsky
2018-11-04 16:40 ` Vitaly Mayatskih
2018-11-05 11:55 ` Maxim Levitsky
2018-11-05 3:00 ` Jason Wang
2018-11-05 3:23 ` Vitaly Mayatskih
2018-11-06 2:45 ` Jason Wang
2018-11-06 2:56 ` Vitaly Mayatskih
2018-11-06 7:13 ` Christoph Hellwig
2018-11-06 21:41 ` Paolo Bonzini
2018-11-05 15:48 ` Christian Borntraeger
2018-11-05 16:15 ` Vitaly Mayatskih
2018-11-06 15:21 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181106160316.GC31579@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=v.mayatskih@gmail.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).