LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Davide Libenzi <davidel@xmailserver.org>
To: Roland Dreier <rdreier@cisco.com>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-fsdevel@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Avi Kivity <avi@qumranet.com>,
	kvm-devel@lists.sourceforge.net,
	Andrew Morton <akpm@linux-foundation.org>,
	Al Viro <viro@ftp.linux.org.uk>
Subject: Re: [PATCH/RFC 1/2] anon-inodes: Remove fd_install() from anon_inode_getfd()
Date: Thu, 28 Feb 2008 12:52:11 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0802281245580.7660@alien.or.mcafeemobile.com> (raw)
In-Reply-To: <adabq60x20d.fsf@cisco.com>

On Thu, 28 Feb 2008, Roland Dreier wrote:

>  > If we let the caller call fd_install(), then it may be messed up WRT 
>  > cleanup (fd, file, inode).
> 
> Yes, that is a tiny bit tricky (need to call put_unused_fd() if you
> don't install the fd).
> 
>  > How about removing the inode pointer handout altogether, and *doing* 
>  > fd_install() inside anon_inode_getfd() like:
>  > 
>  > 	if (pfile != NULL) {
>  > 		get_file(file);
>  > 		*pfile = file;
>  > 	}
>  > 	fd_install(fd, file);
>  > 
>  > In this way, if the caller want the file* back, he gets the reference 
>  > bumped before fd_install().
> 
> 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()?
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;
}

Hmm...?



- Davide



  reply	other threads:[~2008-02-28 20:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080225191043.GA32342@lst.de>
2008-02-27 19:16 ` Roland Dreier
2008-02-27 19:18   ` [PATCH 2/2] IB/uverbs: Use anonymous inodes instead of private filesystem Roland Dreier
2008-02-27 19:20   ` [PATCH/RFC 1/2] anon-inodes: Remove fd_install() from anon_inode_getfd() Avi Kivity
2008-02-27 19:41   ` Davide Libenzi
2008-02-27 20:14     ` Roland Dreier
2008-02-27 20:30       ` Davide Libenzi
2008-02-27 21:05         ` Roland Dreier
2008-02-27 23:42           ` Roland Dreier
2008-02-28  7:52             ` Avi Kivity
2008-02-28 20:04             ` Davide Libenzi
2008-02-28 20:24               ` Roland Dreier
2008-02-28 20:52                 ` Davide Libenzi [this message]
2008-03-05  9:32                   ` [kvm-devel] " Avi Kivity
2008-03-06 15:14             ` Christoph Hellwig
2008-03-09  2:45               ` Roland Dreier
2008-03-17 10:40                 ` Christoph Hellwig
2008-03-17 10:48                   ` Avi Kivity
2008-03-09  2:46               ` Roland Dreier
2008-03-06 15:14   ` Al Viro

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=Pine.LNX.4.64.0802281245580.7660@alien.or.mcafeemobile.com \
    --to=davidel@xmailserver.org \
    --cc=akpm@linux-foundation.org \
    --cc=avi@qumranet.com \
    --cc=hch@lst.de \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdreier@cisco.com \
    --cc=viro@ftp.linux.org.uk \
    --subject='Re: [PATCH/RFC 1/2] anon-inodes: Remove fd_install() from anon_inode_getfd()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).