Skip to content

Commit e4502c6

Browse files
author
Al Viro
committed
ufs: deal with nfsd/iget races
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 2c80929 commit e4502c6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

fs/ufs/ialloc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,10 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
298298
ufsi->i_oeftflag = 0;
299299
ufsi->i_dir_start_lookup = 0;
300300
memset(&ufsi->i_u1, 0, sizeof(ufsi->i_u1));
301-
insert_inode_hash(inode);
301+
if (insert_inode_locked(inode) < 0) {
302+
err = -EIO;
303+
goto failed;
304+
}
302305
mark_inode_dirty(inode);
303306

304307
if (uspi->fs_magic == UFS2_MAGIC) {
@@ -337,6 +340,7 @@ struct inode *ufs_new_inode(struct inode *dir, umode_t mode)
337340
fail_remove_inode:
338341
unlock_ufs(sb);
339342
clear_nlink(inode);
343+
unlock_new_inode(inode);
340344
iput(inode);
341345
UFSD("EXIT (FAILED): err %d\n", err);
342346
return ERR_PTR(err);

fs/ufs/namei.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
3838
{
3939
int err = ufs_add_link(dentry, inode);
4040
if (!err) {
41+
unlock_new_inode(inode);
4142
d_instantiate(dentry, inode);
4243
return 0;
4344
}
4445
inode_dec_link_count(inode);
46+
unlock_new_inode(inode);
4547
iput(inode);
4648
return err;
4749
}
@@ -155,6 +157,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry,
155157

156158
out_fail:
157159
inode_dec_link_count(inode);
160+
unlock_new_inode(inode);
158161
iput(inode);
159162
goto out;
160163
}
@@ -210,6 +213,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
210213
out_fail:
211214
inode_dec_link_count(inode);
212215
inode_dec_link_count(inode);
216+
unlock_new_inode(inode);
213217
iput (inode);
214218
inode_dec_link_count(dir);
215219
unlock_ufs(dir->i_sb);

0 commit comments

Comments
 (0)