The patch titled autofs4 - leave rehashed dentry positive has been removed from the -mm tree. Its filename was autofs4-leave-rehashed-dentry-positive.patch This patch was dropped because an updated version will be merged The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: autofs4 - leave rehashed dentry positive From: Ian Kent <raven@xxxxxxxxxx> 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@xxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Miklos Szeredi <miklos@xxxxxxxxxx> Cc: Jesper Krogh <jesper@xxxxxxxx> Cc: Jeff Moyer <jmoyer@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/autofs4/inode.c | 23 +++++----- fs/autofs4/root.c | 95 ++++++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 51 deletions(-) diff -puN fs/autofs4/inode.c~autofs4-leave-rehashed-dentry-positive fs/autofs4/inode.c --- a/fs/autofs4/inode.c~autofs4-leave-rehashed-dentry-positive +++ a/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(str 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 -puN fs/autofs4/root.c~autofs4-leave-rehashed-dentry-positive fs/autofs4/root.c --- a/fs/autofs4/root.c~autofs4-leave-rehashed-dentry-positive +++ a/fs/autofs4/root.c @@ -555,24 +555,8 @@ static struct dentry *autofs4_lookup_unh 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 in 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 inod 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; _ Patches currently in -mm which might be from raven@xxxxxxxxxx are autofs4-leave-rehashed-dentry-positive.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html