aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2023-10-29 19:09:11 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2023-11-25 02:33:42 -0500
commite9d130d05077e71b1224ad96e419f5f5512b8574 (patch)
tree9aa94f6b6d496b7b5c0829ffd72a3f9e2b4e9225 /fs/dcache.c
parent__dput_to_list(): do decrement of refcount in the callers (diff)
downloadwireguard-linux-e9d130d05077e71b1224ad96e419f5f5512b8574.tar.xz
wireguard-linux-e9d130d05077e71b1224ad96e419f5f5512b8574.zip
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>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 0718b3895c12..2e74f3f2ce2e 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -680,7 +680,6 @@ static inline bool retain_dentry(struct dentry *dentry)
return false;
/* retain; LRU fodder */
- dentry->d_lockref.count--;
if (unlikely(!(dentry->d_flags & DCACHE_LRU_LIST)))
d_lru_add(dentry);
else if (unlikely(!(dentry->d_flags & DCACHE_REFERENCED)))
@@ -744,6 +743,8 @@ got_locks:
} else if (likely(!retain_dentry(dentry))) {
__dentry_kill(dentry);
return parent;
+ } else {
+ dentry->d_lockref.count--;
}
/* we are keeping it, after all */
if (inode)
@@ -893,6 +894,7 @@ void dput(struct dentry *dentry)
rcu_read_unlock();
if (likely(retain_dentry(dentry))) {
+ dentry->d_lockref.count--;
spin_unlock(&dentry->d_lock);
return;
}
@@ -925,6 +927,8 @@ void dput_to_list(struct dentry *dentry, struct list_head *list)
if (!retain_dentry(dentry)) {
--dentry->d_lockref.count;
to_shrink_list(dentry, list);
+ } else {
+ --dentry->d_lockref.count;
}
spin_unlock(&dentry->d_lock);
}