shrink_dentry_list(): no need to check that dentry refcount is marked dead
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 30 Oct 2023 17:57:12 +0000 (13:57 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 25 Nov 2023 07:33:41 +0000 (02:33 -0500)
... we won't see DCACHE_MAY_FREE on anything that is *not* dead
and checking d_flags is just as cheap as checking refcount.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c

index bb862a304e1ba9ddc7b04ad49dd63ebfe55c6b6e..c1025921f8d356eb552527b67e4388dc843aa9dc 100644 (file)
@@ -1191,11 +1191,10 @@ void shrink_dentry_list(struct list_head *list)
                spin_lock(&dentry->d_lock);
                rcu_read_lock();
                if (!shrink_lock_dentry(dentry)) {
-                       bool can_free = false;
+                       bool can_free;
                        rcu_read_unlock();
                        d_shrink_del(dentry);
-                       if (dentry->d_lockref.count < 0)
-                               can_free = dentry->d_flags & DCACHE_MAY_FREE;
+                       can_free = dentry->d_flags & DCACHE_MAY_FREE;
                        spin_unlock(&dentry->d_lock);
                        if (can_free)
                                dentry_free(dentry);