Commit d25cc43c authored by Eric Biggers's avatar Eric Biggers Committed by Michael S. Tsirkin

vhost: don't hold onto file pointer for VHOST_SET_LOG_FD

We already hold a reference to the eventfd_ctx, which is sufficient;
there's no need to hold a reference to the struct file as well.  So get
rid of vhost_dev->log_file.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarJason Wang <jasowang@redhat.com>
parent 09f332a5
...@@ -419,7 +419,6 @@ void vhost_dev_init(struct vhost_dev *dev, ...@@ -419,7 +419,6 @@ void vhost_dev_init(struct vhost_dev *dev,
dev->nvqs = nvqs; dev->nvqs = nvqs;
mutex_init(&dev->mutex); mutex_init(&dev->mutex);
dev->log_ctx = NULL; dev->log_ctx = NULL;
dev->log_file = NULL;
dev->umem = NULL; dev->umem = NULL;
dev->iotlb = NULL; dev->iotlb = NULL;
dev->mm = NULL; dev->mm = NULL;
...@@ -625,9 +624,6 @@ void vhost_dev_cleanup(struct vhost_dev *dev) ...@@ -625,9 +624,6 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
if (dev->log_ctx) if (dev->log_ctx)
eventfd_ctx_put(dev->log_ctx); eventfd_ctx_put(dev->log_ctx);
dev->log_ctx = NULL; dev->log_ctx = NULL;
if (dev->log_file)
fput(dev->log_file);
dev->log_file = NULL;
/* No one will access memory at this point */ /* No one will access memory at this point */
vhost_umem_clean(dev->umem); vhost_umem_clean(dev->umem);
dev->umem = NULL; dev->umem = NULL;
...@@ -1572,8 +1568,7 @@ EXPORT_SYMBOL_GPL(vhost_init_device_iotlb); ...@@ -1572,8 +1568,7 @@ EXPORT_SYMBOL_GPL(vhost_init_device_iotlb);
/* Caller must have device mutex */ /* Caller must have device mutex */
long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp) long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
{ {
struct file *eventfp, *filep = NULL; struct eventfd_ctx *ctx;
struct eventfd_ctx *ctx = NULL;
u64 p; u64 p;
long r; long r;
int i, fd; int i, fd;
...@@ -1619,19 +1614,12 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp) ...@@ -1619,19 +1614,12 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
r = get_user(fd, (int __user *)argp); r = get_user(fd, (int __user *)argp);
if (r < 0) if (r < 0)
break; break;
eventfp = fd == -1 ? NULL : eventfd_fget(fd); ctx = fd == -1 ? NULL : eventfd_ctx_fdget(fd);
if (IS_ERR(eventfp)) { if (IS_ERR(ctx)) {
r = PTR_ERR(eventfp); r = PTR_ERR(ctx);
break; break;
} }
if (eventfp != d->log_file) { swap(ctx, d->log_ctx);
filep = d->log_file;
d->log_file = eventfp;
ctx = d->log_ctx;
d->log_ctx = eventfp ?
eventfd_ctx_fileget(eventfp) : NULL;
} else
filep = eventfp;
for (i = 0; i < d->nvqs; ++i) { for (i = 0; i < d->nvqs; ++i) {
mutex_lock(&d->vqs[i]->mutex); mutex_lock(&d->vqs[i]->mutex);
d->vqs[i]->log_ctx = d->log_ctx; d->vqs[i]->log_ctx = d->log_ctx;
...@@ -1639,8 +1627,6 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp) ...@@ -1639,8 +1627,6 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
} }
if (ctx) if (ctx)
eventfd_ctx_put(ctx); eventfd_ctx_put(ctx);
if (filep)
fput(filep);
break; break;
default: default:
r = -ENOIOCTLCMD; r = -ENOIOCTLCMD;
......
...@@ -157,7 +157,6 @@ struct vhost_dev { ...@@ -157,7 +157,6 @@ struct vhost_dev {
struct mutex mutex; struct mutex mutex;
struct vhost_virtqueue **vqs; struct vhost_virtqueue **vqs;
int nvqs; int nvqs;
struct file *log_file;
struct eventfd_ctx *log_ctx; struct eventfd_ctx *log_ctx;
struct llist_head work_list; struct llist_head work_list;
struct task_struct *worker; struct task_struct *worker;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment