Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64fd72e

Browse files
author
Al Viro
committed
lift the "already marked killed" case into shrink_dentry_list()
It can happen only when dentry_kill() is called with unlock_on_failure equal to 0 - other callers had dentry pinned until the moment they've got ->d_lock and DCACHE_DENTRY_KILLED is set only after lockref_mark_dead(). IOW, only one of three call sites of dentry_kill() might end up reaching that code. Just move it there. Signed-off-by: Al Viro <[email protected]>
1 parent b6dd6f4 commit 64fd72e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

fs/dcache.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,6 @@ dentry_kill(struct dentry *dentry, int unlock_on_failure)
455455
struct dentry *parent = NULL;
456456
bool can_free = true;
457457

458-
if (unlikely(dentry->d_flags & DCACHE_DENTRY_KILLED)) {
459-
can_free = dentry->d_flags & DCACHE_MAY_FREE;
460-
spin_unlock(&dentry->d_lock);
461-
goto out;
462-
}
463-
464458
inode = dentry->d_inode;
465459
if (inode && !spin_trylock(&inode->i_lock)) {
466460
relock:
@@ -815,6 +809,15 @@ static void shrink_dentry_list(struct list_head *list)
815809
continue;
816810
}
817811

812+
813+
if (unlikely(dentry->d_flags & DCACHE_DENTRY_KILLED)) {
814+
bool can_free = dentry->d_flags & DCACHE_MAY_FREE;
815+
spin_unlock(&dentry->d_lock);
816+
if (can_free)
817+
dentry_free(dentry);
818+
continue;
819+
}
820+
818821
parent = dentry_kill(dentry, 0);
819822
/*
820823
* If dentry_kill returns NULL, we have nothing more to do.

0 commit comments

Comments
 (0)