From: Badari Pulavarty <pbadari@us.ibm.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [RFC] vhost-blk implementation
Date: Mon, 05 Apr 2010 19:27:27 -0700 [thread overview]
Message-ID: <1270520847.28348.17.camel@badari-desktop> (raw)
In-Reply-To: <r2wfbd9d3991004050722lfbe6b0faoeb3090185ccedaa4@mail.gmail.com>
On Mon, 2010-04-05 at 15:22 +0100, Stefan Hajnoczi wrote:
> On Mon, Mar 29, 2010 at 4:41 PM, Badari Pulavarty <pbadari@us.ibm.com> wrote:
> > +static void handle_io_work(struct work_struct *work)
> > +{
> > + struct vhost_blk_io *vbio;
> > + struct vhost_virtqueue *vq;
> > + struct vhost_blk *blk;
> > + int i, ret = 0;
> > + loff_t pos;
> > + uint8_t status = 0;
> > +
> > + vbio = container_of(work, struct vhost_blk_io, work);
> > + blk = vbio->blk;
> > + vq = &blk->dev.vqs[0];
> > + pos = vbio->sector << 8;
> > +
> > + use_mm(blk->dev.mm);
> > +
> > + if (vbio->type & VIRTIO_BLK_T_FLUSH) {
> > + ret = vfs_fsync(vbio->file, vbio->file->f_path.dentry, 1);
> > + } else if (vbio->type & VIRTIO_BLK_T_OUT) {
> > + ret = vfs_writev(vbio->file, vbio->iov, vbio->nvecs, &pos);
> > + } else {
> > + ret = vfs_readv(vbio->file, vbio->iov, vbio->nvecs, &pos);
> > + }
> > +
> > + status = (ret < 0) ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK;
> > + if (copy_to_user(vbio->iov[vbio->nvecs].iov_base, &status, sizeof status) < 0) {
> > + printk("copy to user failed\n");
> > + vhost_discard_vq_desc(vq);
> > + unuse_mm(blk->dev.mm);
> > + return;
>
> Do you need to kfree(vbio) here?
Yes. I do. As mentioned earlier, I haven't fixed error handling yet :(
>
> > +static long vhost_blk_set_backend(struct vhost_blk *n, unsigned index, int fd)
> > +{
> > + struct file *file;
> > + struct vhost_virtqueue *vq;
> > +
> > + file = fget(fd);
> > + if (!file)
> > + return -EBADF;
> > +
> > + vq = n->vqs + index;
> > + mutex_lock(&vq->mutex);
> > + rcu_assign_pointer(vq->private_data, file);
> > + mutex_unlock(&vq->mutex);
> > + return 0;
> > +}
> > +
> > +
> > +static long vhost_blk_ioctl(struct file *f, unsigned int ioctl,
> > + unsigned long arg)
> > +{
> > + struct vhost_blk *n = f->private_data;
> > + void __user *argp = (void __user *)arg;
> > + struct vhost_vring_file backend;
> > + int r;
> > +
> > + switch (ioctl) {
> > + case VHOST_NET_SET_BACKEND:
> > + r = copy_from_user(&backend, argp, sizeof backend);
> > + if (r < 0)
> > + return r;
> > + return vhost_blk_set_backend(n, backend.index, backend.fd);
>
> I don't see backend.index being checked against VHOST_BLK_VQ_MAX.
Yep. You are right. I will add these checks for my next revision.
Thanks,
Badari
prev parent reply other threads:[~2010-04-06 2:27 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-23 1:00 [RFC] vhost-blk implementation Badari Pulavarty
2010-03-23 1:16 ` Anthony Liguori
2010-03-23 1:45 ` Badari Pulavarty
2010-03-23 2:00 ` Anthony Liguori
2010-03-23 2:50 ` Badari Pulavarty
2010-03-23 10:05 ` Avi Kivity
2010-03-23 14:48 ` Badari Pulavarty
2010-03-23 10:03 ` Avi Kivity
2010-03-23 14:55 ` Badari Pulavarty
2010-03-23 16:53 ` Avi Kivity
2010-03-24 20:05 ` Christoph Hellwig
2010-03-25 6:29 ` Avi Kivity
2010-03-25 15:48 ` Christoph Hellwig
2010-03-25 15:51 ` Avi Kivity
2010-03-25 15:00 ` Asdo
2010-04-05 19:59 ` Christoph Hellwig
2010-04-07 0:36 ` [RFC] vhost-blk implementation (v2) Badari Pulavarty
2010-03-23 10:09 ` [RFC] vhost-blk implementation Eran Rom
2010-03-24 20:04 ` Christoph Hellwig
2010-03-24 20:22 ` Badari Pulavarty
2010-03-25 7:57 ` Avi Kivity
2010-03-25 14:36 ` Badari Pulavarty
2010-03-25 15:57 ` Christoph Hellwig
2010-03-26 18:53 ` Eran Rom
2010-04-08 16:17 ` Stefan Hajnoczi
2010-04-05 19:23 ` Christoph Hellwig
2010-04-05 23:17 ` Badari Pulavarty
2010-03-24 20:27 ` Badari Pulavarty
2010-03-29 15:41 ` Badari Pulavarty
2010-03-29 18:20 ` Chris Wright
2010-03-29 20:37 ` Avi Kivity
2010-03-29 22:51 ` Badari Pulavarty
2010-03-29 23:56 ` Chris Wright
2010-03-30 12:43 ` Avi Kivity
2010-04-05 14:22 ` Stefan Hajnoczi
2010-04-06 2:27 ` Badari Pulavarty [this message]
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=1270520847.28348.17.camel@badari-desktop \
--to=pbadari@us.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=stefanha@gmail.com \
/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