From: Eric Biggers <ebiggers3@gmail.com>
To: linux-fsdevel@vger.kernel.org, Al Viro <viro@ZenIV.linux.org.uk>
Cc: kvm@vger.kernel.org, "Michael S . Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Eric Biggers <ebiggers@google.com>
Subject: [PATCH 2/3] vhost: don't hold onto file pointer for VHOST_SET_VRING_ERR
Date: Sat, 6 Jan 2018 14:52:20 -0800 [thread overview]
Message-ID: <20180106225221.1965-3-ebiggers3@gmail.com> (raw)
In-Reply-To: <20180106225221.1965-1-ebiggers3@gmail.com>
From: Eric Biggers <ebiggers@google.com>
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_virtqueue->error.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
drivers/vhost/vhost.c | 18 ++++--------------
drivers/vhost/vhost.h | 1 -
2 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index ba589e87372e..39e184b168ce 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -319,7 +319,6 @@ 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->log_ctx = NULL;
@@ -618,8 +617,6 @@ void vhost_dev_cleanup(struct vhost_dev *dev, bool locked)
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)
@@ -1497,19 +1494,12 @@ 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->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);
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index 41026c7d6842..3fe82323f667 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -96,7 +96,6 @@ struct vhost_virtqueue {
struct vring_used __user *used;
const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS];
struct file *kick;
- struct file *error;
struct eventfd_ctx *call_ctx;
struct eventfd_ctx *error_ctx;
struct eventfd_ctx *log_ctx;
--
2.15.1
next prev parent reply other threads:[~2018-01-06 22:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-06 22:52 [PATCH 0/3] vhost: simplify use of eventfds Eric Biggers
2018-01-06 22:52 ` [PATCH 1/3] vhost: don't hold onto file pointer for VHOST_SET_VRING_CALL Eric Biggers
2018-01-06 22:52 ` Eric Biggers [this message]
2018-01-06 22:52 ` [PATCH 3/3] vhost: don't hold onto file pointer for VHOST_SET_LOG_FD Eric Biggers
2018-01-09 3:20 ` [PATCH 0/3] vhost: simplify use of eventfds Jason Wang
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=20180106225221.1965-3-ebiggers3@gmail.com \
--to=ebiggers3@gmail.com \
--cc=ebiggers@google.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=viro@ZenIV.linux.org.uk \
/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