Re: Linux 2.6.26-rc4

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Al Viro <viro@...>, Miklos Szeredi <miklos@...>, <jesper@...>, <linux-kernel@...>, <linux-fsdevel@...>, Jeff Moyer <jmoyer@...>, Andrew Morton <akpm@...>
Date: Thursday, June 5, 2008 - 3:31 am

On Tue, 2008-06-03 at 08:01 -0700, Linus Torvalds wrote:

Here is a patch for autofs4 to, hopefully, resolve this.

Keep in mind this doesn't address any other autofs4 issues but I it
should allow us to identify if this was in fact the root cause of the
problem Jesper reported.

autofs4 - leave rehashed dentry positive

From: Ian Kent <raven@themaw.net>

Correct the error of making a positive dentry negative after it has been
instantiated.

This involves removing the code in autofs4_lookup_unhashed() that
makes the dentry negative and updating autofs4_dir_symlink() and
autofs4_dir_mkdir() to recognise they have been given a postive
dentry (previously the dentry was always negative) and deal with
it. In addition the dentry info struct initialization, autofs4_init_ino(),
and the symlink free function, ino_lnkfree(), have been made aware
of this possible re-use. This is needed because the current case
re-uses a dentry in order to preserve it's flags as described in
commit f50b6f8691cae2e0064c499dd3ef3f31142987f0.

Signed-off-by: Ian Kent <raven@themaw.net>
---

 fs/autofs4/inode.c |   23 +++++++------
 fs/autofs4/root.c  |   95 ++++++++++++++++++++++++++++++----------------------
 2 files changed, 67 insertions(+), 51 deletions(-)


diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 2fdcf5e..ec9a641 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -24,8 +24,10 @@
 
 static void ino_lnkfree(struct autofs_info *ino)
 {
-	kfree(ino->u.symlink);
-	ino->u.symlink = NULL;
+	if (ino->u.symlink) {
+		kfree(ino->u.symlink);
+		ino->u.symlink = NULL;
+	}
 }
 
 struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
@@ -41,16 +43,17 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
 	if (ino == NULL)
 		return NULL;
 
-	ino->flags = 0;
-	ino->mode = mode;
-	ino->inode = NULL;
-	ino->dentry = NULL;
-	ino->size = 0;
-
-	INIT_LIST_HEAD(&ino->rehash);
+	if (!reinit) {
+		ino->flags = 0;
+		ino->mode = mode;
+		ino->inode = NULL;
+		ino->dentry = NULL;
+		ino->size = 0;
+		INIT_LIST_HEAD(&ino->rehash);
+		atomic_set(&ino->count, 0);
+	}
 
 	ino->last_used = jiffies;
-	atomic_set(&ino->count, 0);
 
 	ino->sbi = sbi;
 
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index edf5b6b..6ce603b 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -555,24 +555,8 @@ static struct dentry *autofs4_lookup_unhashed(struct autofs_sb_info *sbi, struct
 			goto next;
 
 		if (d_unhashed(dentry)) {
-			struct inode *inode = dentry->d_inode;
-
-			ino = autofs4_dentry_ino(dentry);
 			list_del_init(&ino->rehash);
 			dget(dentry);
-			/*
-			 * Make the rehashed dentry negative so the VFS
-			 * behaves as it should.
-			 */
-			if (inode) {
-				dentry->d_inode = NULL;
-				list_del_init(&dentry->d_alias);
-				spin_unlock(&dentry->d_lock);
-				spin_unlock(&sbi->rehash_lock);
-				spin_unlock(&dcache_lock);
-				iput(inode);
-				return dentry;
-			}
 			spin_unlock(&dentry->d_lock);
 			spin_unlock(&sbi->rehash_lock);
 			spin_unlock(&dcache_lock);
@@ -728,35 +712,50 @@ static int autofs4_dir_symlink(struct inode *dir,
 		return -EACCES;
 
 	ino = autofs4_init_ino(ino, sbi, S_IFLNK | 0555);
-	if (ino == NULL)
+	if (!ino)
 		return -ENOSPC;
 
-	ino->size = strlen(symname);
-	ino->u.symlink = cp = kmalloc(ino->size + 1, GFP_KERNEL);
-
-	if (cp == NULL) {
-		kfree(ino);
+	cp = kmalloc(ino->size + 1, GFP_KERNEL);
+	if (!cp) {
+		if (!dentry->d_fsdata)
+			kfree(ino);
 		return -ENOSPC;
 	}
 
 	strcpy(cp, symname);
 
-	inode = autofs4_get_inode(dir->i_sb, ino);
-	d_add(dentry, inode);
+	inode = dentry->d_inode;
+	if (inode)
+		d_rehash(dentry);
+	else {
+		inode = autofs4_get_inode(dir->i_sb, ino);
+		if (!inode) {
+			kfree(cp);
+			if (!dentry->d_fsdata)
+				kfree(ino);
+			return -ENOSPC;
+		}
+
+		d_add(dentry, inode);
 
-	if (dir == dir->i_sb->s_root->d_inode)
-		dentry->d_op = &autofs4_root_dentry_operations;
-	else
-		dentry->d_op = &autofs4_dentry_operations;
+		if (dir == dir->i_sb->s_root->d_inode)
+			dentry->d_op = &autofs4_root_dentry_operations;
+		else
+			dentry->d_op = &autofs4_dentry_operations;
+
+		dentry->d_fsdata = ino;
+		ino->dentry = dentry;
+		ino->inode = inode;
+	}
+	dget(dentry);
 
-	dentry->d_fsdata = ino;
-	ino->dentry = dget(dentry);
 	atomic_inc(&ino->count);
 	p_ino = autofs4_dentry_ino(dentry->d_parent);
 	if (p_ino && dentry->d_parent != dentry)
 		atomic_inc(&p_ino->count);
-	ino->inode = inode;
 
+	ino->u.symlink = cp;
+	ino->size = strlen(symname);
 	dir->i_mtime = CURRENT_TIME;
 
 	return 0;
@@ -866,24 +865,38 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 		dentry, dentry->d_name.len, dentry->d_name.name);
 
 	ino = autofs4_init_ino(ino, sbi, S_IFDIR | 0555);
-	if (ino == NULL)
+	if (!ino)
 		return -ENOSPC;
 
-	inode = autofs4_get_inode(dir->i_sb, ino);
-	d_add(dentry, inode);
+	inode = dentry->d_inode;
+	if (inode)
+		d_rehash(dentry);
+	else {
+		inode = autofs4_get_inode(dir->i_sb, ino);
+		if (!inode) {
+			if (!dentry->d_fsdata)
+				kfree(ino);
+			return -ENOSPC;
+		}
 
-	if (dir == dir->i_sb->s_root->d_inode)
-		dentry->d_op = &autofs4_root_dentry_operations;
-	else
-		dentry->d_op = &autofs4_dentry_operations;
+		d_add(dentry, inode);
+
+		if (dir == dir->i_sb->s_root->d_inode)
+			dentry->d_op = &autofs4_root_dentry_operations;
+		else
+			dentry->d_op = &autofs4_dentry_operations;
+
+		dentry->d_fsdata = ino;
+		ino->dentry = dentry;
+		ino->inode = inode;
+	}
+	dget(dentry);
 
-	dentry->d_fsdata = ino;
-	ino->dentry = dget(dentry);
 	atomic_inc(&ino->count);
 	p_ino = autofs4_dentry_ino(dentry->d_parent);
 	if (p_ino && dentry->d_parent != dentry)
 		atomic_inc(&p_ino->count);
-	ino->inode = inode;
+
 	inc_nlink(dir);
 	dir->i_mtime = CURRENT_TIME;
 


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Linux 2.6.26-rc4, Linus Torvalds, (Mon May 26, 2:41 pm)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Wed Jun 4, 1:51 pm)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Tue Jun 3, 5:49 am)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 5:57 am)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 6:35 am)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Tue Jun 3, 6:04 am)
Re: Linux 2.6.26-rc4, Miklos Szeredi, (Tue Jun 3, 6:13 am)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 6:40 am)
Re: Linux 2.6.26-rc4, Miklos Szeredi, (Tue Jun 3, 6:45 am)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 6:52 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 9:27 am)
Re: Linux 2.6.26-rc4, Linus Torvalds, (Tue Jun 3, 11:01 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Thu Jun 5, 3:31 am)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Fri Jun 6, 2:23 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Fri Jun 6, 4:21 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Fri Jun 6, 4:25 am)
Re: Linux 2.6.26-rc4, Andrew Morton, (Thu Jun 5, 6:30 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Fri Jun 27, 12:18 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Thu Jun 5, 10:47 pm)
Re: Linux 2.6.26-rc4, Linus Torvalds, (Thu Jun 5, 5:29 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Thu Jun 5, 10:39 pm)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Thu Jun 5, 5:34 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 12:07 pm)
Re: Linux 2.6.26-rc4, Linus Torvalds, (Tue Jun 3, 12:35 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 1:13 pm)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 1:30 pm)
Re: Linux 2.6.26-rc4, Jeff Moyer, (Tue Jun 3, 1:46 pm)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 3:18 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 9:36 pm)
Re: Linux 2.6.26-rc4, Jeff Moyer, (Tue Jun 3, 3:53 pm)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 7:00 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 10:42 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 10, 12:57 am)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Tue Jun 10, 2:28 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 10, 2:40 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Wed Jun 11, 11:03 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Thu Jun 12, 7:19 am)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Thu Jun 12, 3:02 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Thu Jun 12, 7:21 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 10, 5:09 am)
Re: Linux 2.6.26-rc4, Miklos Szeredi, (Wed Jun 4, 1:34 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Wed Jun 4, 1:41 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 1:38 pm)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 12:41 pm)
Re: Linux 2.6.26-rc4, Linus Torvalds, (Tue Jun 3, 12:59 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 1:30 pm)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 12:50 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 1:28 pm)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 1:41 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 1:41 pm)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 1:50 pm)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 1:49 pm)
Re: Linux 2.6.26-rc4, Miklos Szeredi, (Tue Jun 3, 6:37 am)
Re: Linux 2.6.26-rc4, Al Viro, (Tue Jun 3, 6:48 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 9:31 am)
Re: Linux 2.6.26-rc4, Ian Kent, (Tue Jun 3, 9:32 am)
Re: Linux 2.6.26-rc4, J.A. , (Tue May 27, 6:01 am)
Re: Linux 2.6.26-rc4, Bill Davidsen, (Wed May 28, 7:59 pm)
2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Alexey Dobriyan, (Tue May 27, 1:23 am)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Oleg Nesterov, (Tue May 27, 5:06 am)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Linus Torvalds, (Tue May 27, 11:03 am)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Oleg Nesterov, (Tue May 27, 12:45 pm)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Oleg Nesterov, (Tue May 27, 1:37 pm)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Alexey Dobriyan, (Tue May 27, 5:26 pm)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Paul E. McKenney, (Tue May 27, 11:40 am)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Linus Torvalds, (Tue May 27, 12:11 pm)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Paul E. McKenney, (Tue May 27, 1:06 pm)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Paul E. McKenney, (Wed May 28, 1:01 am)
Re: 2.6.26-rc4: RIP find_pid_ns+0x6b/0xa0, Paul E. McKenney, (Wed May 28, 3:26 am)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Mon May 26, 5:24 pm)
Re: Linux 2.6.26-rc4, Linus Torvalds, (Mon May 26, 5:42 pm)
Re: Linux 2.6.26-rc4, Carl-Daniel Hailfinger, (Mon May 26, 9:16 pm)
Re: Linux 2.6.26-rc4, Jeff Garzik, (Tue May 27, 6:35 am)
Re: Linux 2.6.26-rc4, Carl-Daniel Hailfinger, (Tue May 27, 6:53 am)
Re: Linux 2.6.26-rc4, Jeff Garzik, (Tue May 27, 6:54 am)
Re: Linux 2.6.26-rc4, Carl-Daniel Hailfinger, (Tue May 27, 6:58 am)
Re: Linux 2.6.26-rc4, Carl-Daniel Hailfinger, (Mon May 26, 9:23 pm)
Re: Linux 2.6.26-rc4, Abhijit Menon-Sen, (Mon May 26, 9:52 pm)
Re: Linux 2.6.26-rc4, David Woodhouse, (Tue May 27, 1:31 am)
[MTD] [MAPS] ck804rom: fix driver_data in probe table., David Woodhouse, (Tue May 27, 1:31 am)
Re: Linux 2.6.26-rc4, Jesper Krogh, (Tue May 27, 1:19 am)
Re: Linux 2.6.26-rc4, Arjan van de Ven, (Mon May 26, 8:25 pm)
Re: Linux 2.6.26-rc4, David Woodhouse, (Tue May 27, 1:43 am)
Re: Linux 2.6.26-rc4, Arjan van de Ven, (Tue May 27, 2:00 am)
Re: Linux 2.6.26-rc4, David Woodhouse, (Tue May 27, 2:24 am)
Re: Linux 2.6.26-rc4, Arjan van de Ven, (Mon May 26, 8:31 pm)