Skip to content

Commit 759a7c6

Browse files
josephhzakpm00
authored andcommitted
ocfs2: fix BUG when iput after ocfs2_mknod fails
Commit b1529a4 "ocfs2: should reclaim the inode if '__ocfs2_mknod_locked' returns an error" tried to reclaim the claimed inode if __ocfs2_mknod_locked() fails later. But this introduce a race, the freed bit may be reused immediately by another thread, which will update dinode, e.g. i_generation. Then iput this inode will lead to BUG: inode->i_generation != le32_to_cpu(fe->i_generation) We could make this inode as bad, but we did want to do operations like wipe in some cases. Since the claimed inode bit can only affect that an dinode is missing and will return back after fsck, it seems not a big problem. So just leave it as is by revert the reclaim logic. Link: https://lkml.kernel.org/r/[email protected] Fixes: b1529a4 ("ocfs2: should reclaim the inode if '__ocfs2_mknod_locked' returns an error") Signed-off-by: Joseph Qi <[email protected]> Reported-by: Yan Wang <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 977ef30 commit 759a7c6

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

fs/ocfs2/namei.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -632,18 +632,9 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
632632
return status;
633633
}
634634

635-
status = __ocfs2_mknod_locked(dir, inode, dev, new_fe_bh,
635+
return __ocfs2_mknod_locked(dir, inode, dev, new_fe_bh,
636636
parent_fe_bh, handle, inode_ac,
637637
fe_blkno, suballoc_loc, suballoc_bit);
638-
if (status < 0) {
639-
u64 bg_blkno = ocfs2_which_suballoc_group(fe_blkno, suballoc_bit);
640-
int tmp = ocfs2_free_suballoc_bits(handle, inode_ac->ac_inode,
641-
inode_ac->ac_bh, suballoc_bit, bg_blkno, 1);
642-
if (tmp)
643-
mlog_errno(tmp);
644-
}
645-
646-
return status;
647638
}
648639

649640
static int ocfs2_mkdir(struct user_namespace *mnt_userns,

0 commit comments

Comments
 (0)