summaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-01-06 17:52:21 -0500
committerMichael S. Tsirkin <mst@redhat.com>2018-02-01 09:26:47 -0500
commitd25cc43c6775bff6b8e3dad97c747954b805e421 (patch)
tree92029ddc6e84b3ff4e2e2d0c66a77067e2d1fba4 /drivers/vhost
parent09f332a589232f524b579ba4319433dcc7c0ed32 (diff)
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: Eric Biggers <ebiggers@google.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/vhost.c24
-rw-r--r--drivers/vhost/vhost.h1
2 files changed, 5 insertions, 20 deletions
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 40a72d15361f..66775446248a 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -419,7 +419,6 @@ void vhost_dev_init(struct vhost_dev *dev,
419 dev->nvqs = nvqs; 419 dev->nvqs = nvqs;
420 mutex_init(&dev->mutex); 420 mutex_init(&dev->mutex);
421 dev->log_ctx = NULL; 421 dev->log_ctx = NULL;
422 dev->log_file = NULL;
423 dev->umem = NULL; 422 dev->umem = NULL;
424 dev->iotlb = NULL; 423 dev->iotlb = NULL;
425 dev->mm = NULL; 424 dev->mm = NULL;
@@ -625,9 +624,6 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
625 if (dev->log_ctx) 624 if (dev->log_ctx)
626 eventfd_ctx_put(dev->log_ctx); 625 eventfd_ctx_put(dev->log_ctx);
627 dev->log_ctx = NULL; 626 dev->log_ctx = NULL;
628 if (dev->log_file)
629 fput(dev->log_file);
630 dev->log_file = NULL;
631 /* No one will access memory at this point */ 627 /* No one will access memory at this point */
632 vhost_umem_clean(dev->umem); 628 vhost_umem_clean(dev->umem);
633 dev->umem = NULL; 629 dev->umem = NULL;
@@ -1572,8 +1568,7 @@ EXPORT_SYMBOL_GPL(vhost_init_device_iotlb);
1572/* Caller must have device mutex */ 1568/* Caller must have device mutex */
1573long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp) 1569long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
1574{ 1570{
1575 struct file *eventfp, *filep = NULL; 1571 struct eventfd_ctx *ctx;
1576 struct eventfd_ctx *ctx = NULL;
1577 u64 p; 1572 u64 p;
1578 long r; 1573 long r;
1579 int i, fd; 1574 int i, fd;
@@ -1619,19 +1614,12 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
1619 r = get_user(fd, (int __user *)argp); 1614 r = get_user(fd, (int __user *)argp);
1620 if (r < 0) 1615 if (r < 0)
1621 break; 1616 break;
1622 eventfp = fd == -1 ? NULL : eventfd_fget(fd); 1617 ctx = fd == -1 ? NULL : eventfd_ctx_fdget(fd);
1623 if (IS_ERR(eventfp)) { 1618 if (IS_ERR(ctx)) {
1624 r = PTR_ERR(eventfp); 1619 r = PTR_ERR(ctx);
1625 break; 1620 break;
1626 } 1621 }
1627 if (eventfp != d->log_file) { 1622 swap(ctx, d->log_ctx);
1628 filep = d->log_file;
1629 d->log_file = eventfp;
1630 ctx = d->log_ctx;
1631 d->log_ctx = eventfp ?
1632 eventfd_ctx_fileget(eventfp) : NULL;
1633 } else
1634 filep = eventfp;
1635 for (i = 0; i < d->nvqs; ++i) { 1623 for (i = 0; i < d->nvqs; ++i) {
1636 mutex_lock(&d->vqs[i]->mutex); 1624 mutex_lock(&d->vqs[i]->mutex);
1637 d->vqs[i]->log_ctx = d->log_ctx; 1625 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 } 1627 }
1640 if (ctx) 1628 if (ctx)
1641 eventfd_ctx_put(ctx); 1629 eventfd_ctx_put(ctx);
1642 if (filep)
1643 fput(filep);
1644 break; 1630 break;
1645 default: 1631 default:
1646 r = -ENOIOCTLCMD; 1632 r = -ENOIOCTLCMD;
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index e3c463ce3d48..45d12b01cfe4 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -157,7 +157,6 @@ struct vhost_dev {
157 struct mutex mutex; 157 struct mutex mutex;
158 struct vhost_virtqueue **vqs; 158 struct vhost_virtqueue **vqs;
159 int nvqs; 159 int nvqs;
160 struct file *log_file;
161 struct eventfd_ctx *log_ctx; 160 struct eventfd_ctx *log_ctx;
162 struct llist_head work_list; 161 struct llist_head work_list;
163 struct task_struct *worker; 162 struct task_struct *worker;