summaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2023-10-30 05:43:48 +0100
committerAl Viro <viro@zeniv.linux.org.uk>2023-11-25 08:33:42 +0100
commit6511f6be777f3b06e904c7407fd9f2a39dae8b67 (patch)
tree451786e6a8667bfa66f98cd1a6e026e034937b22 /fs/dcache.c
parentfast_dput(): new rules for refcount (diff)
downloadlinux-6511f6be777f3b06e904c7407fd9f2a39dae8b67.tar.xz
linux-6511f6be777f3b06e904c7407fd9f2a39dae8b67.zip
__dput_to_list(): do decrement of refcount in the callers
... and rename it to to_shrink_list(), seeing that it no longer does dropping any references 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.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index a00e9ba22480..0718b3895c12 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -902,16 +902,13 @@ void dput(struct dentry *dentry)
}
EXPORT_SYMBOL(dput);
-static void __dput_to_list(struct dentry *dentry, struct list_head *list)
+static void to_shrink_list(struct dentry *dentry, struct list_head *list)
__must_hold(&dentry->d_lock)
{
- if (dentry->d_flags & DCACHE_SHRINK_LIST) {
- /* let the owner of the list it's on deal with it */
- --dentry->d_lockref.count;
- } else {
+ if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) {
if (dentry->d_flags & DCACHE_LRU_LIST)
d_lru_del(dentry);
- if (!--dentry->d_lockref.count)
+ if (!dentry->d_lockref.count)
d_shrink_add(dentry, list);
}
}
@@ -925,8 +922,10 @@ void dput_to_list(struct dentry *dentry, struct list_head *list)
}
rcu_read_unlock();
dentry->d_lockref.count = 1;
- if (!retain_dentry(dentry))
- __dput_to_list(dentry, list);
+ if (!retain_dentry(dentry)) {
+ --dentry->d_lockref.count;
+ to_shrink_list(dentry, list);
+ }
spin_unlock(&dentry->d_lock);
}
@@ -1165,8 +1164,10 @@ out:
static inline void shrink_kill(struct dentry *victim, struct list_head *list)
{
struct dentry *parent = victim->d_parent;
- if (parent != victim)
- __dput_to_list(parent, list);
+ if (parent != victim) {
+ --parent->d_lockref.count;
+ to_shrink_list(parent, list);
+ }
__dentry_kill(victim);
}