Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio/vhost updates from Michael Tsirkin: "virtio, vhost: fixes, cleanups, features This includes the disk/cache memory stats for for the virtio balloon, as well as multiple fixes and cleanups" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: vhost: don't hold onto file pointer for VHOST_SET_LOG_FD vhost: don't hold onto file pointer for VHOST_SET_VRING_ERR vhost: don't hold onto file pointer for VHOST_SET_VRING_CALL ringtest: ring.c malloc & memset to calloc virtio_vop: don't kfree device on register failure virtio_pci: don't kfree device on register failure virtio: split device_register into device_initialize and device_add vhost: remove unused lock check flag in vhost_dev_cleanup() vhost: Remove the unused variable. virtio_blk: print capacity at probe time virtio: make VIRTIO a menuconfig to ease disabling it all virtio/ringtest: virtio_ring: fix up need_event math virtio/ringtest: fix up need_event math virtio: virtio_mmio: make of_device_ids const. firmware: Use PTR_ERR_OR_ZERO() virtio-mmio: Use PTR_ERR_OR_ZERO() vhost/scsi: Improve a size determination in four functions virtio_balloon: include disk/file caches memory statistics
This commit is contained in:
@@ -181,7 +181,6 @@ void vhost_work_init(struct vhost_work *work, vhost_work_fn_t fn)
|
||||
{
|
||||
clear_bit(VHOST_WORK_QUEUED, &work->flags);
|
||||
work->fn = fn;
|
||||
init_waitqueue_head(&work->done);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vhost_work_init);
|
||||
|
||||
@@ -319,10 +318,8 @@ static void vhost_vq_reset(struct vhost_dev *dev,
|
||||
vq->acked_features = 0;
|
||||
vq->log_base = NULL;
|
||||
vq->error_ctx = NULL;
|
||||
vq->error = NULL;
|
||||
vq->kick = NULL;
|
||||
vq->call_ctx = NULL;
|
||||
vq->call = NULL;
|
||||
vq->log_ctx = NULL;
|
||||
vhost_reset_is_le(vq);
|
||||
vhost_disable_cross_endian(vq);
|
||||
@@ -422,7 +419,6 @@ void vhost_dev_init(struct vhost_dev *dev,
|
||||
dev->nvqs = nvqs;
|
||||
mutex_init(&dev->mutex);
|
||||
dev->log_ctx = NULL;
|
||||
dev->log_file = NULL;
|
||||
dev->umem = NULL;
|
||||
dev->iotlb = NULL;
|
||||
dev->mm = NULL;
|
||||
@@ -544,7 +540,7 @@ void vhost_dev_reset_owner(struct vhost_dev *dev, struct vhost_umem *umem)
|
||||
{
|
||||
int i;
|
||||
|
||||
vhost_dev_cleanup(dev, true);
|
||||
vhost_dev_cleanup(dev);
|
||||
|
||||
/* Restore memory to default empty mapping. */
|
||||
INIT_LIST_HEAD(&umem->umem_list);
|
||||
@@ -611,31 +607,23 @@ static void vhost_clear_msg(struct vhost_dev *dev)
|
||||
spin_unlock(&dev->iotlb_lock);
|
||||
}
|
||||
|
||||
/* Caller should have device mutex if and only if locked is set */
|
||||
void vhost_dev_cleanup(struct vhost_dev *dev, bool locked)
|
||||
void vhost_dev_cleanup(struct vhost_dev *dev)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < dev->nvqs; ++i) {
|
||||
if (dev->vqs[i]->error_ctx)
|
||||
eventfd_ctx_put(dev->vqs[i]->error_ctx);
|
||||
if (dev->vqs[i]->error)
|
||||
fput(dev->vqs[i]->error);
|
||||
if (dev->vqs[i]->kick)
|
||||
fput(dev->vqs[i]->kick);
|
||||
if (dev->vqs[i]->call_ctx)
|
||||
eventfd_ctx_put(dev->vqs[i]->call_ctx);
|
||||
if (dev->vqs[i]->call)
|
||||
fput(dev->vqs[i]->call);
|
||||
vhost_vq_reset(dev, dev->vqs[i]);
|
||||
}
|
||||
vhost_dev_free_iovecs(dev);
|
||||
if (dev->log_ctx)
|
||||
eventfd_ctx_put(dev->log_ctx);
|
||||
dev->log_ctx = NULL;
|
||||
if (dev->log_file)
|
||||
fput(dev->log_file);
|
||||
dev->log_file = NULL;
|
||||
/* No one will access memory at this point */
|
||||
vhost_umem_clean(dev->umem);
|
||||
dev->umem = NULL;
|
||||
@@ -1492,38 +1480,24 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
|
||||
r = -EFAULT;
|
||||
break;
|
||||
}
|
||||
eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
|
||||
if (IS_ERR(eventfp)) {
|
||||
r = PTR_ERR(eventfp);
|
||||
ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
|
||||
if (IS_ERR(ctx)) {
|
||||
r = PTR_ERR(ctx);
|
||||
break;
|
||||
}
|
||||
if (eventfp != vq->call) {
|
||||
filep = vq->call;
|
||||
ctx = vq->call_ctx;
|
||||
vq->call = eventfp;
|
||||
vq->call_ctx = eventfp ?
|
||||
eventfd_ctx_fileget(eventfp) : NULL;
|
||||
} else
|
||||
filep = eventfp;
|
||||
swap(ctx, vq->call_ctx);
|
||||
break;
|
||||
case VHOST_SET_VRING_ERR:
|
||||
if (copy_from_user(&f, argp, sizeof f)) {
|
||||
r = -EFAULT;
|
||||
break;
|
||||
}
|
||||
eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
|
||||
if (IS_ERR(eventfp)) {
|
||||
r = PTR_ERR(eventfp);
|
||||
ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
|
||||
if (IS_ERR(ctx)) {
|
||||
r = PTR_ERR(ctx);
|
||||
break;
|
||||
}
|
||||
if (eventfp != vq->error) {
|
||||
filep = vq->error;
|
||||
vq->error = eventfp;
|
||||
ctx = vq->error_ctx;
|
||||
vq->error_ctx = eventfp ?
|
||||
eventfd_ctx_fileget(eventfp) : NULL;
|
||||
} else
|
||||
filep = eventfp;
|
||||
swap(ctx, vq->error_ctx);
|
||||
break;
|
||||
case VHOST_SET_VRING_ENDIAN:
|
||||
r = vhost_set_vring_endian(vq, argp);
|
||||
@@ -1551,7 +1525,7 @@ long vhost_vring_ioctl(struct vhost_dev *d, int ioctl, void __user *argp)
|
||||
if (pollstop && vq->handle_kick)
|
||||
vhost_poll_stop(&vq->poll);
|
||||
|
||||
if (ctx)
|
||||
if (!IS_ERR_OR_NULL(ctx))
|
||||
eventfd_ctx_put(ctx);
|
||||
if (filep)
|
||||
fput(filep);
|
||||
@@ -1594,8 +1568,7 @@ EXPORT_SYMBOL_GPL(vhost_init_device_iotlb);
|
||||
/* Caller must have device mutex */
|
||||
long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
|
||||
{
|
||||
struct file *eventfp, *filep = NULL;
|
||||
struct eventfd_ctx *ctx = NULL;
|
||||
struct eventfd_ctx *ctx;
|
||||
u64 p;
|
||||
long r;
|
||||
int i, fd;
|
||||
@@ -1641,19 +1614,12 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
|
||||
r = get_user(fd, (int __user *)argp);
|
||||
if (r < 0)
|
||||
break;
|
||||
eventfp = fd == -1 ? NULL : eventfd_fget(fd);
|
||||
if (IS_ERR(eventfp)) {
|
||||
r = PTR_ERR(eventfp);
|
||||
ctx = fd == -1 ? NULL : eventfd_ctx_fdget(fd);
|
||||
if (IS_ERR(ctx)) {
|
||||
r = PTR_ERR(ctx);
|
||||
break;
|
||||
}
|
||||
if (eventfp != d->log_file) {
|
||||
filep = d->log_file;
|
||||
d->log_file = eventfp;
|
||||
ctx = d->log_ctx;
|
||||
d->log_ctx = eventfp ?
|
||||
eventfd_ctx_fileget(eventfp) : NULL;
|
||||
} else
|
||||
filep = eventfp;
|
||||
swap(ctx, d->log_ctx);
|
||||
for (i = 0; i < d->nvqs; ++i) {
|
||||
mutex_lock(&d->vqs[i]->mutex);
|
||||
d->vqs[i]->log_ctx = d->log_ctx;
|
||||
@@ -1661,8 +1627,6 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
|
||||
}
|
||||
if (ctx)
|
||||
eventfd_ctx_put(ctx);
|
||||
if (filep)
|
||||
fput(filep);
|
||||
break;
|
||||
default:
|
||||
r = -ENOIOCTLCMD;
|
||||
|
Reference in New Issue
Block a user