From patchwork Sat Jan 6 22:52:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10148067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5331D60153 for ; Sat, 6 Jan 2018 22:58:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41BF128769 for ; Sat, 6 Jan 2018 22:58:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 353F8287F9; Sat, 6 Jan 2018 22:58:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E620D28769 for ; Sat, 6 Jan 2018 22:58:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752992AbeAFW6o (ORCPT ); Sat, 6 Jan 2018 17:58:44 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:36471 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751915AbeAFW6m (ORCPT ); Sat, 6 Jan 2018 17:58:42 -0500 Received: by mail-pg0-f65.google.com with SMTP id j2so2193981pgv.3; Sat, 06 Jan 2018 14:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rh9sxu5bpWA6kkutlWjTkV48Pk5czOm3CAUZSr+jQX0=; b=K8lRqUPlKumWO/xb4NBpAEeHuhhvJBpcwRrRpOGiK4TPwrcF4VvcbWTjcxfxmAFs2n aSPMymXSTnbxU2qf3MJHS/F0nz6RZixW4Ud3dpggtAtedmHVSmbx4Jfd2VU86gX/XH99 f/NkQWZY4HeJtHWS0gGi6CvGZtsNzvnxSJX5qtZv9L9pMH/Qg4b7L2rtAHohfbHvtRhN yLaZoLUKoPwQH2Nu4CTLT0oYTnSK2hCV+Eb8+YRyZ9hfWuCdGyV+flnOl4kXD50jC55N nH4IXFiCLrZA7Kx+O+iBduX2t8RhazqTD1rECpE7aNKKSZ8ZzuDmLc83v3qD7iswEWbn XqAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rh9sxu5bpWA6kkutlWjTkV48Pk5czOm3CAUZSr+jQX0=; b=SG1vPhM8jlL8d1iw/B0JCmWFU902M6Yp8z2YRb4t5pZMxXQXUEocKm6rs0LwUDeuHO dZkAqBNewmRZ5DQ8tavuPvA/2PvZpjslcXIw75wZAqAR9Z9tfczlrpDmtsS26GLmJoYQ U0cRe6vn/Z1ugBVMRtWJnYBEHIIj9Ng2ufR9rvWJeYhzlagLGUg9G9ik0HMdzFPDDbHC E/2gOStcJHPhW8pyOB8wenXFKpN+Bw5UjImXahN0m0HoeXrQSECxDHa5Com0cXdwn9PQ vuFXbmaO8OWs0EnKyRO1aljC/hJ7ftxpW7G1lJzIx580i5L5unu/6MQDnTcGqLNQ58+L 0UIg== X-Gm-Message-State: AKGB3mLSNVE0Vv7Xr0fV6lzyAcKx+dLnmZ1B8jIoF5Mh6BIF1j8ugC4h OI9a/GvyrVg45ToIvnQCRfupEZSI X-Google-Smtp-Source: ACJfBos5zgA+XH7dyGRwlefdkPav4INszMYwc+4SWl7p43m1rFVJ1Xm74hV4YlsNL2mHISTLiMHDgQ== X-Received: by 10.98.209.10 with SMTP id z10mr6799497pfg.151.1515279521685; Sat, 06 Jan 2018 14:58:41 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id u21sm17904039pfl.102.2018.01.06.14.58.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jan 2018 14:58:41 -0800 (PST) From: Eric Biggers To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kvm@vger.kernel.org, "Michael S . Tsirkin" , Jason Wang , Eric Biggers 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 Message-Id: <20180106225221.1965-3-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180106225221.1965-1-ebiggers3@gmail.com> References: <20180106225221.1965-1-ebiggers3@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers 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 --- 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;