From b754f16d44d3689acc92ff3d255f8f9b61425db3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 30 Dec 2008 01:52:35 -0500 Subject: [PATCH] --- yaml --- r: 125010 b: refs/heads/master c: 41080b5a240113328c607f22b849f653373db0ce h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/ext2/ialloc.c | 6 +++++- trunk/fs/ext2/namei.c | 15 ++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index b8a8c33b3444..0050c39dfddf 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 261bca86ed4f7f391d1938167624e78da61dcc6b +refs/heads/master: 41080b5a240113328c607f22b849f653373db0ce diff --git a/trunk/fs/ext2/ialloc.c b/trunk/fs/ext2/ialloc.c index 8d0add625870..c454d5db28a5 100644 --- a/trunk/fs/ext2/ialloc.c +++ b/trunk/fs/ext2/ialloc.c @@ -585,7 +585,10 @@ struct inode *ext2_new_inode(struct inode *dir, int mode) spin_lock(&sbi->s_next_gen_lock); inode->i_generation = sbi->s_next_generation++; spin_unlock(&sbi->s_next_gen_lock); - insert_inode_hash(inode); + if (insert_inode_locked(inode) < 0) { + err = -EINVAL; + goto fail_drop; + } if (DQUOT_ALLOC_INODE(inode)) { err = -EDQUOT; @@ -612,6 +615,7 @@ struct inode *ext2_new_inode(struct inode *dir, int mode) DQUOT_DROP(inode); inode->i_flags |= S_NOQUOTA; inode->i_nlink = 0; + unlock_new_inode(inode); iput(inode); return ERR_PTR(err); diff --git a/trunk/fs/ext2/namei.c b/trunk/fs/ext2/namei.c index 2a747252ec12..90ea17998a73 100644 --- a/trunk/fs/ext2/namei.c +++ b/trunk/fs/ext2/namei.c @@ -41,9 +41,11 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) int err = ext2_add_link(dentry, inode); if (!err) { d_instantiate(dentry, inode); + unlock_new_inode(inode); return 0; } inode_dec_link_count(inode); + unlock_new_inode(inode); iput(inode); return err; } @@ -170,6 +172,7 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry, out_fail: inode_dec_link_count(inode); + unlock_new_inode(inode); iput (inode); goto out; } @@ -178,6 +181,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir, struct dentry *dentry) { struct inode *inode = old_dentry->d_inode; + int err; if (inode->i_nlink >= EXT2_LINK_MAX) return -EMLINK; @@ -186,7 +190,14 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir, inode_inc_link_count(inode); atomic_inc(&inode->i_count); - return ext2_add_nondir(dentry, inode); + err = ext2_add_link(dentry, inode); + if (!err) { + d_instantiate(dentry, inode); + return 0; + } + inode_dec_link_count(inode); + iput(inode); + return err; } static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) @@ -222,12 +233,14 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) goto out_fail; d_instantiate(dentry, inode); + unlock_new_inode(inode); out: return err; out_fail: inode_dec_link_count(inode); inode_dec_link_count(inode); + unlock_new_inode(inode); iput(inode); out_dir: inode_dec_link_count(dir);