Skip to content

Commit 928dda1

Browse files
jiangyiwen123torvalds
authored andcommitted
ocfs2: fix a tiny case that inode can not removed
When running dirop_fileop_racer we found a case that inode can not removed. Two nodes, say Node A and Node B, mount the same ocfs2 volume. Create two dirs /race/1/ and /race/2/ in the filesystem. Node A Node B rm -r /race/2/ mv /race/1/ /race/2/ call ocfs2_unlink(), get the EX mode of /race/2/ wait for B unlock /race/2/ decrease i_nlink of /race/2/ to 0, and add inode of /race/2/ into orphan dir, unlock /race/2/ got EX mode of /race/2/. because /race/1/ is dir, so inc i_nlink of /race/2/ and update into disk, unlock /race/2/ because i_nlink of /race/2/ is not zero, this inode will always remain in orphan dir This patch fixes this case by test whether i_nlink of new dir is zero. Signed-off-by: Yiwen Jiang <[email protected]> Reviewed-by: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Joseph Qi <[email protected]> Cc: Xue jiufei <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6ab855a commit 928dda1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/ocfs2/namei.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,11 @@ static int ocfs2_rename(struct inode *old_dir,
13091309
}
13101310
parents_locked = 1;
13111311

1312+
if (!new_dir->i_nlink) {
1313+
status = -EACCES;
1314+
goto bail;
1315+
}
1316+
13121317
/* make sure both dirs have bhs
13131318
* get an extra ref on old_dir_bh if old==new */
13141319
if (!new_dir_bh) {

0 commit comments

Comments
 (0)