Skip to content

Commit e9d130d

Browse files
author
Al Viro
committed
make retain_dentry() neutral with respect to refcounting
retain_dentry() used to decrement refcount if and only if it returned true. Lift those decrements into the callers. Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 6511f6b commit e9d130d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/dcache.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,6 @@ static inline bool retain_dentry(struct dentry *dentry)
680680
return false;
681681

682682
/* retain; LRU fodder */
683-
dentry->d_lockref.count--;
684683
if (unlikely(!(dentry->d_flags & DCACHE_LRU_LIST)))
685684
d_lru_add(dentry);
686685
else if (unlikely(!(dentry->d_flags & DCACHE_REFERENCED)))
@@ -744,6 +743,8 @@ static struct dentry *dentry_kill(struct dentry *dentry)
744743
} else if (likely(!retain_dentry(dentry))) {
745744
__dentry_kill(dentry);
746745
return parent;
746+
} else {
747+
dentry->d_lockref.count--;
747748
}
748749
/* we are keeping it, after all */
749750
if (inode)
@@ -893,6 +894,7 @@ void dput(struct dentry *dentry)
893894
rcu_read_unlock();
894895

895896
if (likely(retain_dentry(dentry))) {
897+
dentry->d_lockref.count--;
896898
spin_unlock(&dentry->d_lock);
897899
return;
898900
}
@@ -925,6 +927,8 @@ void dput_to_list(struct dentry *dentry, struct list_head *list)
925927
if (!retain_dentry(dentry)) {
926928
--dentry->d_lockref.count;
927929
to_shrink_list(dentry, list);
930+
} else {
931+
--dentry->d_lockref.count;
928932
}
929933
spin_unlock(&dentry->d_lock);
930934
}

0 commit comments

Comments
 (0)