ufs: deal with nfsd/iget races
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 27 Sep 2014 01:17:52 +0000 (21:17 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 27 Sep 2014 01:17:52 +0000 (21:17 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ufs/ialloc.c
fs/ufs/namei.c

index a9cc75ffa925f995c35bc592651681ee3ff63e24..7caa016528883c6d8b8e7234ef0adc7ce23c6044 100644 (file)
@@ -298,7 +298,10 @@ cg_found:
        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) {
@@ -337,6 +340,7 @@ cg_found:
 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);
index 2df62a73f20ce2071c17d81c343ada85ae287d2a..fd65deb4b5f095e3103028b83f214ffba73707f7 100644 (file)
@@ -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;
 }
@@ -155,6 +157,7 @@ out_notlocked:
 
 out_fail:
        inode_dec_link_count(inode);
+       unlock_new_inode(inode);
        iput(inode);
        goto out;
 }
@@ -210,6 +213,7 @@ out:
 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);