]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: unconditionally use atime_needs_update() in pick_link()
authorMateusz Guzik <mjguzik@gmail.com>
Tue, 8 Apr 2025 07:36:41 +0000 (09:36 +0200)
committerChristian Brauner <brauner@kernel.org>
Tue, 8 Apr 2025 09:08:24 +0000 (11:08 +0200)
Vast majority of the time the func returns false.

This avoids a branch to determine whether we are in RCU mode.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://lore.kernel.org/20250408073641.1799151-1-mjguzik@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namei.c

index 360a86ca1f0270ca34d6bd49cc46dfb8361e0b3b..ae2643ff14dc795d7847a9d1d377acda86c159cb 100644 (file)
@@ -1905,13 +1905,13 @@ static const char *pick_link(struct nameidata *nd, struct path *link,
                        unlikely(link->mnt->mnt_flags & MNT_NOSYMFOLLOW))
                return ERR_PTR(-ELOOP);
 
-       if (!(nd->flags & LOOKUP_RCU)) {
+       if (unlikely(atime_needs_update(&last->link, inode))) {
+               if (nd->flags & LOOKUP_RCU) {
+                       if (!try_to_unlazy(nd))
+                               return ERR_PTR(-ECHILD);
+               }
                touch_atime(&last->link);
                cond_resched();
-       } else if (atime_needs_update(&last->link, inode)) {
-               if (!try_to_unlazy(nd))
-                       return ERR_PTR(-ECHILD);
-               touch_atime(&last->link);
        }
 
        error = security_inode_follow_link(link->dentry, inode,