fs/dcache: Re-use value stored to dentry->d_flags instead of re-reading
authorlinke li <lilinke99@qq.com>
Wed, 3 Apr 2024 02:10:08 +0000 (10:10 +0800)
committerChristian Brauner <brauner@kernel.org>
Tue, 9 Apr 2024 10:29:03 +0000 (12:29 +0200)
Currently, the __d_clear_type_and_inode() writes the value flags to
dentry->d_flags, then immediately re-reads it in order to use it in a if
statement. This re-read is useless because no other update to
dentry->d_flags can occur at this point.

This commit therefore re-use flags in the if statement instead of
re-reading dentry->d_flags.

Signed-off-by: linke li <lilinke99@qq.com>
Link: https://lore.kernel.org/r/tencent_5E187BD0A61BA28605E85405F15228254D0A@qq.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/dcache.c

index 71a8e943a0fa506c93fd7f11400de9a5d7e23e01..407095188f83a7faeec0a8c0542fb6598952b7be 100644 (file)
@@ -355,7 +355,7 @@ static inline void __d_clear_type_and_inode(struct dentry *dentry)
        flags &= ~DCACHE_ENTRY_TYPE;
        WRITE_ONCE(dentry->d_flags, flags);
        dentry->d_inode = NULL;
-       if (dentry->d_flags & DCACHE_LRU_LIST)
+       if (flags & DCACHE_LRU_LIST)
                this_cpu_inc(nr_dentry_negative);
 }