public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] fs: avoid calls to legitimize_links() if possible
Date: Mon, 10 Nov 2025 01:27:05 +0000	[thread overview]
Message-ID: <20251110012705.GI2441659@ZenIV> (raw)
In-Reply-To: <20251109185409.1330720-1-mjguzik@gmail.com>

On Sun, Nov 09, 2025 at 07:54:09PM +0100, Mateusz Guzik wrote:

> @@ -882,8 +887,10 @@ static bool try_to_unlazy(struct nameidata *nd)
>  
>  	BUG_ON(!(nd->flags & LOOKUP_RCU));
>  
> -	if (unlikely(!legitimize_links(nd)))
> -		goto out1;
> +	if (unlikely(need_legitimize_links(nd))) {
> +		if (unlikely(!legitimize_links(nd)))
> +			goto out1;
> +	}
>  	if (unlikely(!legitimize_path(nd, &nd->path, nd->seq)))
>  		goto out;
>  	if (unlikely(!legitimize_root(nd)))
> @@ -917,8 +924,10 @@ static bool try_to_unlazy_next(struct nameidata *nd, struct dentry *dentry)
>  	int res;
>  	BUG_ON(!(nd->flags & LOOKUP_RCU));
>  
> -	if (unlikely(!legitimize_links(nd)))
> -		goto out2;
> +	if (unlikely(need_legitimize_links(nd))) {
> +		if (unlikely(!legitimize_links(nd)))
> +			goto out2;
> +	}
>  	res = __legitimize_mnt(nd->path.mnt, nd->m_seq);
>  	if (unlikely(res)) {
>  		if (res > 0)

Seeing that odds of extra callers showing up are pretty much nil,
I think your need_legitimize_links() is only obfuscating things.
Let's just make it
	if (unlikely(nd->depth) && !legitimize_links(nd))
		goto ...
and be done with that.

      reply	other threads:[~2025-11-10  1:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-09 18:54 [PATCH] fs: avoid calls to legitimize_links() if possible Mateusz Guzik
2025-11-10  1:27 ` Al Viro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251110012705.GI2441659@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox