[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251110012705.GI2441659@ZenIV>
Date: Mon, 10 Nov 2025 01:27:05 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Mateusz Guzik <mjguzik@...il.com>
Cc: brauner@...nel.org, jack@...e.cz, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] fs: avoid calls to legitimize_links() if possible
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.
Powered by blists - more mailing lists