Re: [PATCH v3] fs: make sure to fail try_to_unlazy() and try_to_unlazy() for LOOKUP_CACHED

From: Al Viro

Date: Sat Dec 20 2025 - 03:57:44 EST


On Sat, Dec 20, 2025 at 06:40:22AM +0100, Mateusz Guzik wrote:
> Otherwise the slowpath can be taken by the caller, defeating the flag.
>
> This regressed after calls to legitimize_links() started being
> conditionally elided and stems from the routine always failing
> after seeing the flag, regardless if there were any links.
>
> In order to address both the bug and the weird semantics make it illegal
> to call legitimize_links() with LOOKUP_CACHED and handle the problem at
> the two callsites.

I still don't get what's weird about the semantics involved, but
the only question I've got is the location of this VFS_BUG_ON().
A way to ensure that we don't forget to check LOOKUP_CACHED early,
in both (seriously similar) callers?

Anyway, it does fix the regression.