[PATCH 5/6] vfs: remove LOOKUP_PARENT from non LOOKUP_PARENT lookup

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: OGAWA Hirofumi
Date: Wednesday, October 15, 2008 - 6:58 am

lookup_hash() with LOOKUP_PARENT is bogus. And this prepares to add
new intent on those path.

The user of LOOKUP_PARENT intent is nfs only, and it checks whether
nd->flags has LOOKUP_CREATE or LOOKUP_OPEN, so the result is same.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 fs/namei.c |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff -puN fs/namei.c~dcache-remove-parent fs/namei.c
--- linux-2.6/fs/namei.c~dcache-remove-parent	2008-08-26 11:13:30.000000000 +0900
+++ linux-2.6-hirofumi/fs/namei.c	2008-08-26 11:13:30.000000000 +0900
@@ -2176,16 +2176,19 @@ static long do_rmdir(int dfd, const char
 		return error;
 
 	switch(nd.last_type) {
-		case LAST_DOTDOT:
-			error = -ENOTEMPTY;
-			goto exit1;
-		case LAST_DOT:
-			error = -EINVAL;
-			goto exit1;
-		case LAST_ROOT:
-			error = -EBUSY;
-			goto exit1;
+	case LAST_DOTDOT:
+		error = -ENOTEMPTY;
+		goto exit1;
+	case LAST_DOT:
+		error = -EINVAL;
+		goto exit1;
+	case LAST_ROOT:
+		error = -EBUSY;
+		goto exit1;
 	}
+
+	nd.flags &= ~LOOKUP_PARENT;
+
 	mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
 	dentry = lookup_hash(&nd);
 	error = PTR_ERR(dentry);
@@ -2263,6 +2266,9 @@ static long do_unlinkat(int dfd, const c
 	error = -EISDIR;
 	if (nd.last_type != LAST_NORM)
 		goto exit1;
+
+	nd.flags &= ~LOOKUP_PARENT;
+
 	mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
 	dentry = lookup_hash(&nd);
 	error = PTR_ERR(dentry);
@@ -2652,6 +2658,9 @@ asmlinkage long sys_renameat(int olddfd,
 	if (newnd.last_type != LAST_NORM)
 		goto exit2;
 
+	oldnd.flags &= ~LOOKUP_PARENT;
+	newnd.flags &= ~LOOKUP_PARENT;
+
 	trap = lock_rename(new_dir, old_dir);
 
 	old_dentry = lookup_hash(&oldnd);
_
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 3/6] vfs: add __d_instantiate() helper, OGAWA Hirofumi, (Wed Oct 15, 6:58 am)
[PATCH 2/6] vfs: add d_ancestor(), OGAWA Hirofumi, (Wed Oct 15, 6:58 am)
[PATCH 6/6] vfs: add LOOKUP_RENAME_NEW intent, OGAWA Hirofumi, (Wed Oct 15, 6:58 am)
[PATCH 5/6] vfs: remove LOOKUP_PARENT from non LOOKUP_PARE ..., OGAWA Hirofumi, (Wed Oct 15, 6:58 am)
Re: [PATCH 6/6] vfs: add LOOKUP_RENAME_NEW intent, Christoph Hellwig, (Wed Oct 15, 12:37 pm)
Re: [PATCH 3/6] vfs: add __d_instantiate() helper, Christoph Hellwig, (Wed Oct 15, 12:41 pm)
Re: [PATCH 4/6] vfs: remove unnecessary fsnotify_d_instant ..., Christoph Hellwig, (Wed Oct 15, 12:43 pm)
Re: [PATCH 5/6] vfs: remove LOOKUP_PARENT from non LOOKUP_ ..., Christoph Hellwig, (Wed Oct 15, 12:44 pm)
Re: [PATCH 2/6] vfs: add d_ancestor(), Christoph Hellwig, (Wed Oct 15, 12:53 pm)
Re: [PATCH 6/6] vfs: add LOOKUP_RENAME_NEW intent, OGAWA Hirofumi, (Wed Oct 15, 1:13 pm)
Re: [PATCH 4/6] vfs: remove unnecessary fsnotify_d_instant ..., Christoph Hellwig, (Wed Oct 15, 1:20 pm)
Re: [PATCH 3/6] vfs: add __d_instantiate() helper, OGAWA Hirofumi, (Wed Oct 15, 1:39 pm)
Re: [PATCH 3/6] vfs: add __d_instantiate() helper, Trond Myklebust, (Wed Oct 15, 1:47 pm)
Re: [PATCH 3/6] vfs: add __d_instantiate() helper, OGAWA Hirofumi, (Wed Oct 15, 2:31 pm)
Re: [PATCH 2/6] vfs: add d_ancestor(), OGAWA Hirofumi, (Wed Oct 15, 2:42 pm)