Merge branch 'fix/asoc' into for-linus
[linux-2.6-block.git] / fs / ext2 / ialloc.c
index 8d0add62587020ab8299e33dd8a6b5ac4edae500..66321a877e7458795616e0568c58fac83e0437fd 100644 (file)
@@ -565,12 +565,8 @@ got:
        inode->i_blocks = 0;
        inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
        memset(ei->i_data, 0, sizeof(ei->i_data));
-       ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL;
-       if (S_ISLNK(mode))
-               ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL);
-       /* dirsync is only applied to directories */
-       if (!S_ISDIR(mode))
-               ei->i_flags &= ~EXT2_DIRSYNC_FL;
+       ei->i_flags =
+               ext2_mask_flags(mode, EXT2_I(dir)->i_flags & EXT2_FL_INHERITED);
        ei->i_faddr = 0;
        ei->i_frag_no = 0;
        ei->i_frag_size = 0;
@@ -585,7 +581,10 @@ got:
        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 +611,7 @@ fail_drop:
        DQUOT_DROP(inode);
        inode->i_flags |= S_NOQUOTA;
        inode->i_nlink = 0;
+       unlock_new_inode(inode);
        iput(inode);
        return ERR_PTR(err);