linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	hch@infradead.org, torvalds@linux-foundation.org,
	mszeredi@suse.cz
Subject: [PATCH 14/16] vfs: nameidata_to_filp(): don't throw away file on error
Date: Mon, 21 May 2012 17:30:18 +0200	[thread overview]
Message-ID: <1337614220-6174-15-git-send-email-miklos@szeredi.hu> (raw)
In-Reply-To: <1337614220-6174-1-git-send-email-miklos@szeredi.hu>

From: Miklos Szeredi <mszeredi@suse.cz>

If open fails, don't put the file.  This allows it to be reused if open needs to
be retried.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/open.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index 161c15f..0510e58 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -814,10 +814,11 @@ struct file *nameidata_to_filp(struct nameidata *nd)
 
 	/* Pick up the filp from the open intent */
 	filp = nd->intent.open.file;
-	nd->intent.open.file = NULL;
 
 	/* Has the filesystem initialised the file for us? */
-	if (filp->f_path.dentry == NULL) {
+	if (filp->f_path.dentry != NULL) {
+		nd->intent.open.file = NULL;
+	} else {
 		struct file *res;
 
 		path_get(&nd->path);
@@ -826,6 +827,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
 		if (!IS_ERR(res)) {
 			int error;
 
+			nd->intent.open.file = NULL;
 			BUG_ON(res != filp);
 
 			error = open_check_o_direct(filp);
@@ -834,7 +836,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
 				filp = ERR_PTR(error);
 			}
 		} else {
-			put_filp(filp);
+			/* Allow nd->intent.open.file to be recycled */
 			filp = res;
 		}
 	}
-- 
1.7.7

  parent reply	other threads:[~2012-05-21 15:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 15:30 [PATCH 00/16] vfs: atomic open v5 (part 1) Miklos Szeredi
2012-05-21 15:30 ` [PATCH 01/16] vfs: split do_lookup() Miklos Szeredi
2012-05-21 15:30 ` [PATCH 02/16] vfs: do_last(): make exit RCU safe Miklos Szeredi
2012-05-21 15:30 ` [PATCH 03/16] vfs: do_last(): inline walk_component() Miklos Szeredi
2012-05-21 15:30 ` [PATCH 04/16] vfs: do_last(): use inode variable Miklos Szeredi
2012-05-21 15:30 ` [PATCH 05/16] vfs: make follow_link check RCU safe Miklos Szeredi
2012-05-21 15:30 ` [PATCH 06/16] vfs: do_last(): make ENOENT exit " Miklos Szeredi
2012-05-21 15:30 ` [PATCH 07/16] vfs: do_last(): check LOOKUP_DIRECTORY Miklos Szeredi
2012-05-21 15:30 ` [PATCH 08/16] vfs: do_last(): only return EISDIR for O_CREAT Miklos Szeredi
2012-05-21 15:30 ` [PATCH 09/16] vfs: do_last(): add audit_inode before open Miklos Szeredi
2012-05-21 15:30 ` [PATCH 10/16] vfs: do_last() common post lookup Miklos Szeredi
2012-05-21 15:30 ` [PATCH 11/16] vfs: split __dentry_open() Miklos Szeredi
2012-05-21 15:30 ` [PATCH 12/16] vfs: do_dentry_open(): don't put filp Miklos Szeredi
2012-05-21 15:30 ` [PATCH 13/16] vfs: nameidata_to_filp(): inline __dentry_open() Miklos Szeredi
2012-05-21 15:30 ` Miklos Szeredi [this message]
2012-05-21 15:30 ` [PATCH 15/16] vfs: retry last component if opening stale dentry Miklos Szeredi
2012-05-21 15:30 ` [PATCH 16/16] nfs: don't open in ->d_revalidate Miklos Szeredi
2012-05-21 16:27 ` [PATCH 00/16] vfs: atomic open v5 (part 1) Linus Torvalds
2012-05-21 20:39   ` Miklos Szeredi
  -- strict thread matches above, loose matches on Subject: below --
2012-04-25 12:44 [PATCH 00/16] vfs: atomic open v4 " Miklos Szeredi
2012-04-25 12:44 ` [PATCH 14/16] vfs: nameidata_to_filp(): don't throw away file on error Miklos Szeredi

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=1337614220-6174-15-git-send-email-miklos@szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mszeredi@suse.cz \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).