Skip to content

Commit

Permalink
nfsd race fixes: ext4
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Dec 31, 2008
1 parent c38012d commit 6b38e84
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion fs/ext4/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,10 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
ext4_set_inode_flags(inode);
if (IS_DIRSYNC(inode))
handle->h_sync = 1;
insert_inode_hash(inode);
if (insert_inode_locked(inode) < 0) {
err = -EINVAL;
goto fail_drop;
}
spin_lock(&sbi->s_next_gen_lock);
inode->i_generation = sbi->s_next_generation++;
spin_unlock(&sbi->s_next_gen_lock);
Expand Down Expand Up @@ -881,6 +884,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
DQUOT_DROP(inode);
inode->i_flags |= S_NOQUOTA;
inode->i_nlink = 0;
unlock_new_inode(inode);
iput(inode);
brelse(bitmap_bh);
return ERR_PTR(err);
Expand Down
14 changes: 13 additions & 1 deletion fs/ext4/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1693,9 +1693,11 @@ static int ext4_add_nondir(handle_t *handle,
if (!err) {
ext4_mark_inode_dirty(handle, inode);
d_instantiate(dentry, inode);
unlock_new_inode(inode);
return 0;
}
drop_nlink(inode);
unlock_new_inode(inode);
iput(inode);
return err;
}
Expand Down Expand Up @@ -1830,6 +1832,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (err) {
out_clear_inode:
clear_nlink(inode);
unlock_new_inode(inode);
ext4_mark_inode_dirty(handle, inode);
iput(inode);
goto out_stop;
Expand All @@ -1838,6 +1841,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
ext4_update_dx_flag(dir);
ext4_mark_inode_dirty(handle, dir);
d_instantiate(dentry, inode);
unlock_new_inode(inode);
out_stop:
ext4_journal_stop(handle);
if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
Expand Down Expand Up @@ -2212,6 +2216,7 @@ static int ext4_symlink(struct inode *dir,
mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
if (err) {
clear_nlink(inode);
unlock_new_inode(inode);
ext4_mark_inode_dirty(handle, inode);
iput(inode);
goto out_stop;
Expand Down Expand Up @@ -2262,7 +2267,14 @@ static int ext4_link(struct dentry *old_dentry,
ext4_inc_count(handle, inode);
atomic_inc(&inode->i_count);

err = ext4_add_nondir(handle, dentry, inode);
err = ext4_add_entry(handle, dentry, inode);
if (!err) {
ext4_mark_inode_dirty(handle, inode);
d_instantiate(dentry, inode);
} else {
drop_nlink(inode);
iput(inode);
}
ext4_journal_stop(handle);
if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
goto retry;
Expand Down

0 comments on commit 6b38e84

Please sign in to comment.