Skip to contentSkip to conversation

fs: unconditionally use atime_needs_update() in pick_link()

PATCH Applied Mateusz Guzik 3 participants 3 messages Apr 8, 2025 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: unconditionally use atime_needs_update() in pick_link()

Vast majority of the time the func returns false.

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

---
 fs/namei.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/namei.c +5 -5
index 360a86ca1f02..ae2643ff14dc 100644
@@ -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,
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Mateusz Guzik

Vast majority of the time the func returns false.

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

Applied to the vfs-6.16.misc branch of the vfs/vfs.git tree. Patches in the vfs-6.16.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.16.misc

[1/1] fs: unconditionally use atime_needs_update() in pick_link()

      https://git.kernel.org/vfs/vfs/c/e45960c279b0
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Mateusz Guzik
Quoted 5 lines · Mateusz Guzik

Vast majority of the time the func returns false.

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

Looks good! Feel free to add:

Honza

Quoted 30 lines
---
 fs/namei.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/namei.c +5 -5
index 360a86ca1f02..ae2643ff14dc 100644
@@ -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,
Signature · 1 line
2.43.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR