Skip to content

Commit b06c684

Browse files
author
Al Viro
committed
dentry_kill(): don't bother with retain_dentry() on slow path
We have already checked it and dentry used to look not worthy of keeping. The only hard obstacle to evicting dentry is non-zero refcount; everything else is advisory - e.g. memory pressure could evict any dentry found with refcount zero. On the slow path in dentry_kill() we had dropped and regained ->d_lock; we must recheck the refcount, but everything else is not worth bothering with. Note that filesystem can not count upon ->d_delete() being called for dentry - not even once. Again, memory pressure (as well as d_prune_aliases(), or attempted rmdir() of ancestor, or...) will not call ->d_delete() at all. So from the correctness point of view we are fine doing the check only once. And it makes things simpler down the road. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent ee0c825 commit b06c684

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

fs/dcache.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -739,14 +739,10 @@ static struct dentry *dentry_kill(struct dentry *dentry)
739739
spin_lock(&dentry->d_lock);
740740
parent = lock_parent(dentry);
741741
got_locks:
742-
if (unlikely(dentry->d_lockref.count != 1)) {
743-
dentry->d_lockref.count--;
744-
} else if (likely(!retain_dentry(dentry))) {
745-
dentry->d_lockref.count--;
742+
dentry->d_lockref.count--;
743+
if (likely(dentry->d_lockref.count == 0)) {
746744
__dentry_kill(dentry);
747745
return parent;
748-
} else {
749-
dentry->d_lockref.count--;
750746
}
751747
/* we are keeping it, after all */
752748
if (inode)

0 commit comments

Comments
 (0)