Skip to content

Commit 10ab881

Browse files
alex chentorvalds
authored andcommitted
ocfs2: prune the dcache before deleting the dentry of directory
In ocfs2_dentry_convert_worker, we should prune the dcache before deleting the dentry of directory, otherwise, in the following cases the inode of directory will still remain in orphan directory until the device being umounted. Mount point: /mnt/ocfs2 Node A Node B mkdir /mnt/ocfs2/testdir ocfs2_mkdir ->ocfs2_mknod ->ocfs2_dentry_attach_lock ->ocfs2_dentry_lock(dentry, 0) ... ... touch /mnt/ocfs2/testdir/testfile unlink /mnt/test/testdir/testfile rmdir /mnt/ocfs2/testdir ocfs2_unlink ->ocfs2_remote_dentry_delete ->ocfs2_dentry_lock(dentry, 1) ... ... ... ... ocfs2_downconvert_thread ->ocfs2_unblock_lock ->ocfs2_dentry_convert_worker ->ocfs2_find_local_alias ->dget_dlock ->d_delete Here the dentry can not be released because the children's dentry is negative but still exist. Finally, this inode will still remain in orphan directory until its children are destroyed. So before deleting dentry of directory, we should prune the dcache to remove unused children of the parent dentry by shrink_dcache_parent(). Signed-off-by: Alex Chen <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Reviewed-by: joyce.xue <[email protected]> Reviewed-by: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 8989b67 commit 10ab881

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/ocfs2/dlmglue.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3750,6 +3750,9 @@ static int ocfs2_dentry_convert_worker(struct ocfs2_lock_res *lockres,
37503750
break;
37513751
spin_unlock(&dentry_attach_lock);
37523752

3753+
if (S_ISDIR(dl->dl_inode->i_mode))
3754+
shrink_dcache_parent(dentry);
3755+
37533756
mlog(0, "d_delete(%pd);\n", dentry);
37543757

37553758
/*

0 commit comments

Comments
 (0)