Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
[firefly-linux-kernel-4.4.55.git] / fs / ocfs2 / namei.c
index 1206392a071ffd9d1bd21312c8e727be29afabfa..a03f6f433075c02d3c87c192b362d2c7f2e96952 100644 (file)
@@ -372,6 +372,8 @@ static int ocfs2_mknod(struct inode *dir,
                mlog_errno(status);
                goto leave;
        }
+       /* update inode->i_mode after mask with "umask". */
+       inode->i_mode = mode;
 
        handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb,
                                                            S_ISDIR(mode),
@@ -655,9 +657,18 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
                return status;
        }
 
-       return __ocfs2_mknod_locked(dir, inode, dev, new_fe_bh,
+       status = __ocfs2_mknod_locked(dir, inode, dev, new_fe_bh,
                                    parent_fe_bh, handle, inode_ac,
                                    fe_blkno, suballoc_loc, suballoc_bit);
+       if (status < 0) {
+               u64 bg_blkno = ocfs2_which_suballoc_group(fe_blkno, suballoc_bit);
+               int tmp = ocfs2_free_suballoc_bits(handle, inode_ac->ac_inode,
+                               inode_ac->ac_bh, suballoc_bit, bg_blkno, 1);
+               if (tmp)
+                       mlog_errno(tmp);
+       }
+
+       return status;
 }
 
 static int ocfs2_mkdir(struct inode *dir,