Skip to content

Commit

Permalink
ufs: deal with nfsd/iget races
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Sep 27, 2014
1 parent 2c80929 commit e4502c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ufs/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,10 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
ufsi->i_oeftflag = 0;
ufsi->i_dir_start_lookup = 0;
memset(&ufsi->i_u1, 0, sizeof(ufsi->i_u1));
insert_inode_hash(inode);
if (insert_inode_locked(inode) < 0) {
err = -EIO;
goto failed;
}
mark_inode_dirty(inode);

if (uspi->fs_magic == UFS2_MAGIC) {
Expand Down Expand Up @@ -337,6 +340,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
fail_remove_inode:
unlock_ufs(sb);
clear_nlink(inode);
unlock_new_inode(inode);
iput(inode);
UFSD("EXIT (FAILED): err %d\n", err);
return ERR_PTR(err);
Expand Down
4 changes: 4 additions & 0 deletions fs/ufs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
{
int err = ufs_add_link(dentry, inode);
if (!err) {
unlock_new_inode(inode);
d_instantiate(dentry, inode);
return 0;
}
inode_dec_link_count(inode);
unlock_new_inode(inode);
iput(inode);
return err;
}
Expand Down Expand Up @@ -155,6 +157,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,

out_fail:
inode_dec_link_count(inode);
unlock_new_inode(inode);
iput(inode);
goto out;
}
Expand Down Expand Up @@ -210,6 +213,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
out_fail:
inode_dec_link_count(inode);
inode_dec_link_count(inode);
unlock_new_inode(inode);
iput (inode);
inode_dec_link_count(dir);
unlock_ufs(dir->i_sb);
Expand Down

0 comments on commit e4502c6

Please sign in to comment.