From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762743AbYCEJgh (ORCPT ); Wed, 5 Mar 2008 04:36:37 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757742AbYCEJgJ (ORCPT ); Wed, 5 Mar 2008 04:36:09 -0500 Received: from bzq-179-150-194.static.bezeqint.net ([212.179.150.194]:51086 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757005AbYCEJgH (ORCPT ); Wed, 5 Mar 2008 04:36:07 -0500 Message-ID: <47CE68BE.7000201@qumranet.com> Date: Wed, 05 Mar 2008 11:32:46 +0200 From: Avi Kivity User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Davide Libenzi CC: Roland Dreier , kvm-devel@lists.sourceforge.net, Linux Kernel Mailing List , Al Viro , linux-fsdevel@vger.kernel.org, Andrew Morton , Christoph Hellwig Subject: Re: [kvm-devel] [PATCH/RFC 1/2] anon-inodes: Remove fd_install() from anon_inode_getfd() References: <20080225191043.GA32342@lst.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0rc1 (firebolt.argo.co.il [0.0.0.0]); Wed, 05 Mar 2008 11:32:47 +0200 (IST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Davide Libenzi wrote: >> I think that may be a bit cleaner than Al's approach, but it still >> leaves the same trap that create_vcpu_fd() falls into. The current >> code is: >> >> static int create_vcpu_fd(struct kvm_vcpu *vcpu) >> { >> int fd, r; >> struct inode *inode; >> struct file *file; >> >> r = anon_inode_getfd(&fd, &inode, &file, >> "kvm-vcpu", &kvm_vcpu_fops, vcpu); >> if (r) >> return r; >> atomic_inc(&vcpu->kvm->filp->f_count); >> return fd; >> } >> >> and with your proposal, the natural way to write that becomes: >> >> static int create_vcpu_fd(struct kvm_vcpu *vcpu) >> { >> int fd, r; >> >> r = anon_inode_getfd(&fd, NULL, >> "kvm-vcpu", &kvm_vcpu_fops, vcpu); >> if (r) >> return r; >> atomic_inc(&vcpu->kvm->filp->f_count); >> return fd; >> } >> > > I don't know KVM code, but can't the "private_data" setup be completed > before calling anon_inode_getfd()? > Creating the fd is the last thing done when creating a vcpu. > Or ... > > static int create_vcpu_fd(struct kvm_vcpu *vcpu) > { > int fd, r; > > get_file(vcpu->kvm->filp); > r = anon_inode_getfd(&fd, NULL, > "kvm-vcpu", &kvm_vcpu_fops, vcpu); > if (r) { > fput(vcpu->kvm->filp); > return r; > } > return fd; > } > This seems reasonable. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.