From: Christoph Hellwig <hch@infradead.org>
To: Dave Hansen <haveblue@us.ibm.com>
Cc: linux-kernel@vger.kernel.org, miklos@szeredi.hu, hch@infradead.org
Subject: Re: [RFC][PATCH 5/5] make open_namei() return a filp
Date: Thu, 27 Sep 2007 19:55:37 +0100 [thread overview]
Message-ID: <20070927185537.GA521@infradead.org> (raw)
In-Reply-To: <20070927185215.8ADB5392@kernel>
On Thu, Sep 27, 2007 at 11:52:15AM -0700, Dave Hansen wrote:
> If open_namei() succeeds, there is potentially a mnt_want_write()
> that needs to get balanced. If the caller doesn't create a
> 'struct file' and eventually __fput() it, or manually drop the
> write count on an error, we have a bug.
>
> Forcing open_namei() to return a filp fixes this. Any caller
> getting a 'struct file' back must consider that filp instantiated
> and fput() it normally. The callers no longer have to worry about
> ever manually releasing a mnt write count.
> diff -puN fs/open.c~make-open_namei-return-a-filp fs/open.c
> --- lxc/fs/open.c~make-open_namei-return-a-filp 2007-09-27 11:51:34.000000000 -0700
> +++ lxc-dave/fs/open.c 2007-09-27 11:51:34.000000000 -0700
> @@ -846,11 +846,7 @@ static struct file *do_filp_open(int dfd
> int error;
> struct nameidata nd;
>
> - error = open_namei(dfd, filename, flags, mode, &nd);
> - if (!error)
> - return nameidata_to_filp(&nd, flags);
> -
> - return ERR_PTR(error);
> + return open_namei(dfd, filename, flags, mode, &nd);
Error is unused now, and it's also rather silly to allocate the
nd here when it's only used inside open_namei. So I'd suggest
killing do_filp_open, and maybe filp_open aswell while you're at
it.
prev parent reply other threads:[~2007-09-27 18:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-27 18:52 [RFC][PATCH 1/5] get mount write in __dentry_open() Dave Hansen
2007-09-27 18:52 ` [RFC][PATCH 2/5] move mnt_want_write() into open_namei_create() Dave Hansen
2007-09-27 18:52 ` [RFC][PATCH 3/5] move mnt_want_write() out of may_open() Dave Hansen
2007-09-27 18:52 ` [RFC][PATCH 4/5] do namei_flags calculation inside open_namei() Dave Hansen
2007-09-27 18:52 ` [RFC][PATCH 5/5] make open_namei() return a filp Dave Hansen
2007-09-27 18:55 ` Christoph Hellwig [this message]
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=20070927185537.GA521@infradead.org \
--to=hch@infradead.org \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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