kill DCACHE_MAY_FREE
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 10 Nov 2023 19:07:43 +0000 (14:07 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 25 Nov 2023 07:51:52 +0000 (02:51 -0500)
With the new ordering in __dentry_kill() it has become redundant -
it's set if and only if both DCACHE_DENTRY_KILLED and DCACHE_SHRINK_LIST
are set.

We set it in __dentry_kill(), after having set DCACHE_DENTRY_KILLED
with the only condition being that DCACHE_SHRINK_LIST is there;
all of that is done without dropping ->d_lock and the only place
that checks that flag (shrink_dentry_list()) does so under ->d_lock,
after having found the victim on its shrink list.  Since DCACHE_SHRINK_LIST
is set only when placing dentry into shrink list and removed only by
shrink_dentry_list() itself, a check for DCACHE_DENTRY_KILLED in
there would be equivalent to check for DCACHE_MAY_FREE.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c
include/linux/dcache.h

index 475ef1e..523cbf0 100644 (file)
@@ -614,10 +614,8 @@ static struct dentry *__dentry_kill(struct dentry *dentry)
        }
        spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
        dentry_unlist(dentry);
-       if (dentry->d_flags & DCACHE_SHRINK_LIST) {
-               dentry->d_flags |= DCACHE_MAY_FREE;
+       if (dentry->d_flags & DCACHE_SHRINK_LIST)
                can_free = false;
-       }
        spin_unlock(&dentry->d_lock);
        if (likely(can_free))
                dentry_free(dentry);
@@ -1072,7 +1070,7 @@ void shrink_dentry_list(struct list_head *list)
                        bool can_free;
                        rcu_read_unlock();
                        d_shrink_del(dentry);
-                       can_free = dentry->d_flags & DCACHE_MAY_FREE;
+                       can_free = dentry->d_flags & DCACHE_DENTRY_KILLED;
                        spin_unlock(&dentry->d_lock);
                        if (can_free)
                                dentry_free(dentry);
index b4449a1..48b3935 100644 (file)
@@ -202,7 +202,6 @@ struct dentry_operations {
 #define DCACHE_SPECIAL_TYPE            (5 << 20) /* Other file type */
 #define DCACHE_SYMLINK_TYPE            (6 << 20) /* Symlink */
 
-#define DCACHE_MAY_FREE                        BIT(23)
 #define DCACHE_NOKEY_NAME              BIT(25) /* Encrypted name encoded without key */
 #define DCACHE_OP_REAL                 BIT(26)