diff mbox series

fs: unconditionally use atime_needs_update() in pick_link()

Message ID 20250408073641.1799151-1-mjguzik@gmail.com (mailing list archive)
State New
Headers show
Series fs: unconditionally use atime_needs_update() in pick_link() | expand

Commit Message

Mateusz Guzik April 8, 2025, 7:36 a.m. UTC
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>
---
 fs/namei.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Christian Brauner April 8, 2025, 9:09 a.m. UTC | #1
On Tue, 08 Apr 2025 09:36:41 +0200, Mateusz Guzik wrote:
> 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
Jan Kara April 8, 2025, 12:07 p.m. UTC | #2
On Tue 08-04-25 09:36:41, Mateusz Guzik wrote:
> 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>

Looks good! Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/namei.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/namei.c b/fs/namei.c
> index 360a86ca1f02..ae2643ff14dc 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -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,
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/fs/namei.c b/fs/namei.c
index 360a86ca1f02..ae2643ff14dc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -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,