From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69009C47257 for ; Fri, 8 May 2020 15:55:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45FBA21841 for ; Fri, 8 May 2020 15:55:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HTy0LP80" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728094AbgEHPzP (ORCPT ); Fri, 8 May 2020 11:55:15 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:32963 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727124AbgEHPzO (ORCPT ); Fri, 8 May 2020 11:55:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588953313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o2NuVDMsNek1XqDZ23KXOT0aYU3U9mtuti+eij0cQ3Y=; b=HTy0LP80TBlJ0td1X6hUOfBc0VINV17hEJUBeOoqpmYBDJ5iV72NaVB8nREn37l0OCHTU8 KrsIqbd0GeyrM/rC4YgsDVPFx1UUSX1JRfddT+4tUAIDhvGZJMvaoyiNDo7IY6r0TmgO7/ y5iPg2bDQCjQGMV3BaakDuiKxYs0vTM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-tB1ktjf7Nd6ZDjXX8AJRsw-1; Fri, 08 May 2020 11:55:11 -0400 X-MC-Unique: tB1ktjf7Nd6ZDjXX8AJRsw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59A41107ACCA; Fri, 8 May 2020 15:55:09 +0000 (UTC) Received: from w520.home (ovpn-113-111.phx2.redhat.com [10.3.113.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id 615F6341E3; Fri, 8 May 2020 15:55:08 +0000 (UTC) Date: Fri, 8 May 2020 09:55:07 -0600 From: Alex Williamson To: Christoph Hellwig Cc: Alexander Viro , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 08/12] vfio: use __anon_inode_getfd Message-ID: <20200508095507.54051943@w520.home> In-Reply-To: <20200508153634.249933-9-hch@lst.de> References: <20200508153634.249933-1-hch@lst.de> <20200508153634.249933-9-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Fri, 8 May 2020 17:36:30 +0200 Christoph Hellwig wrote: > Use __anon_inode_getfd instead of opencoding the logic using > get_unused_fd_flags + anon_inode_getfile. > > Signed-off-by: Christoph Hellwig > --- > drivers/vfio/vfio.c | 37 ++++++++----------------------------- > 1 file changed, 8 insertions(+), 29 deletions(-) Thanks! Acked-by: Alex Williamson > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c > index 765e0e5d83ed9..33a88103f857f 100644 > --- a/drivers/vfio/vfio.c > +++ b/drivers/vfio/vfio.c > @@ -1451,42 +1451,21 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf) > return ret; > } > > - /* > - * We can't use anon_inode_getfd() because we need to modify > - * the f_mode flags directly to allow more than just ioctls > - */ > - ret = get_unused_fd_flags(O_CLOEXEC); > - if (ret < 0) { > - device->ops->release(device->device_data); > - vfio_device_put(device); > - return ret; > - } > - > - filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops, > - device, O_RDWR); > - if (IS_ERR(filep)) { > - put_unused_fd(ret); > - ret = PTR_ERR(filep); > - device->ops->release(device->device_data); > - vfio_device_put(device); > - return ret; > - } > - > - /* > - * TODO: add an anon_inode interface to do this. > - * Appears to be missing by lack of need rather than > - * explicitly prevented. Now there's need. > - */ > + ret = __anon_inode_getfd("[vfio-device]", &vfio_device_fops, > + device, O_CLOEXEC | O_RDWR, &filep); > + if (ret < 0) > + goto release; > filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); > - > atomic_inc(&group->container_users); > - > fd_install(ret, filep); > > if (group->noiommu) > dev_warn(device->dev, "vfio-noiommu device opened by user " > "(%s:%d)\n", current->comm, task_pid_nr(current)); > - > + return ret; > +release: > + device->ops->release(device->device_data); > + vfio_device_put(device); > return ret; > } > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97CA1C54E4A for ; Fri, 8 May 2020 15:55:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6FD5D21473 for ; Fri, 8 May 2020 15:55:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HTy0LP80" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FD5D21473 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4AEF6EB29; Fri, 8 May 2020 15:55:15 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 763616EB29 for ; Fri, 8 May 2020 15:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588953313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o2NuVDMsNek1XqDZ23KXOT0aYU3U9mtuti+eij0cQ3Y=; b=HTy0LP80TBlJ0td1X6hUOfBc0VINV17hEJUBeOoqpmYBDJ5iV72NaVB8nREn37l0OCHTU8 KrsIqbd0GeyrM/rC4YgsDVPFx1UUSX1JRfddT+4tUAIDhvGZJMvaoyiNDo7IY6r0TmgO7/ y5iPg2bDQCjQGMV3BaakDuiKxYs0vTM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-172-tB1ktjf7Nd6ZDjXX8AJRsw-1; Fri, 08 May 2020 11:55:11 -0400 X-MC-Unique: tB1ktjf7Nd6ZDjXX8AJRsw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59A41107ACCA; Fri, 8 May 2020 15:55:09 +0000 (UTC) Received: from w520.home (ovpn-113-111.phx2.redhat.com [10.3.113.111]) by smtp.corp.redhat.com (Postfix) with ESMTP id 615F6341E3; Fri, 8 May 2020 15:55:08 +0000 (UTC) Date: Fri, 8 May 2020 09:55:07 -0600 From: Alex Williamson To: Christoph Hellwig Subject: Re: [PATCH 08/12] vfio: use __anon_inode_getfd Message-ID: <20200508095507.54051943@w520.home> In-Reply-To: <20200508153634.249933-9-hch@lst.de> References: <20200508153634.249933-1-hch@lst.de> <20200508153634.249933-9-hch@lst.de> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bpf@vger.kernel.org, kvm@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-gpio@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, io-uring@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, 8 May 2020 17:36:30 +0200 Christoph Hellwig wrote: > Use __anon_inode_getfd instead of opencoding the logic using > get_unused_fd_flags + anon_inode_getfile. > > Signed-off-by: Christoph Hellwig > --- > drivers/vfio/vfio.c | 37 ++++++++----------------------------- > 1 file changed, 8 insertions(+), 29 deletions(-) Thanks! Acked-by: Alex Williamson > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c > index 765e0e5d83ed9..33a88103f857f 100644 > --- a/drivers/vfio/vfio.c > +++ b/drivers/vfio/vfio.c > @@ -1451,42 +1451,21 @@ static int vfio_group_get_device_fd(struct vfio_group *group, char *buf) > return ret; > } > > - /* > - * We can't use anon_inode_getfd() because we need to modify > - * the f_mode flags directly to allow more than just ioctls > - */ > - ret = get_unused_fd_flags(O_CLOEXEC); > - if (ret < 0) { > - device->ops->release(device->device_data); > - vfio_device_put(device); > - return ret; > - } > - > - filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops, > - device, O_RDWR); > - if (IS_ERR(filep)) { > - put_unused_fd(ret); > - ret = PTR_ERR(filep); > - device->ops->release(device->device_data); > - vfio_device_put(device); > - return ret; > - } > - > - /* > - * TODO: add an anon_inode interface to do this. > - * Appears to be missing by lack of need rather than > - * explicitly prevented. Now there's need. > - */ > + ret = __anon_inode_getfd("[vfio-device]", &vfio_device_fops, > + device, O_CLOEXEC | O_RDWR, &filep); > + if (ret < 0) > + goto release; > filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE); > - > atomic_inc(&group->container_users); > - > fd_install(ret, filep); > > if (group->noiommu) > dev_warn(device->dev, "vfio-noiommu device opened by user " > "(%s:%d)\n", current->comm, task_pid_nr(current)); > - > + return ret; > +release: > + device->ops->release(device->device_data); > + vfio_device_put(device); > return ret; > } > _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel