Skip to content

Commit ee0c825

Browse files
author
Al Viro
committed
__dentry_kill(): get consistent rules for victim's refcount
Currently we call it with refcount equal to 1 when called from dentry_kill(); all other callers have it equal to 0. Make it always be called with zero refcount; on this step we just decrement it before the calls in dentry_kill(). That is safe, since all places that care about the value of refcount either do that under ->d_lock or hold a reference to dentry in question. Either is sufficient to prevent observing a dentry immediately prior to __dentry_kill() getting called from dentry_kill(). Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e9d130d commit ee0c825

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/dcache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
729729
goto slow_positive;
730730
}
731731
}
732+
dentry->d_lockref.count--;
732733
__dentry_kill(dentry);
733734
return parent;
734735

@@ -741,6 +742,7 @@ static struct dentry *dentry_kill(struct dentry *dentry)
741742
if (unlikely(dentry->d_lockref.count != 1)) {
742743
dentry->d_lockref.count--;
743744
} else if (likely(!retain_dentry(dentry))) {
745+
dentry->d_lockref.count--;
744746
__dentry_kill(dentry);
745747
return parent;
746748
} else {

0 commit comments

Comments
 (0)