Re: [GIT PULL] vfs mount

Christian Brauner
2025-04-07T11:22:26Z

On Fri, Apr 04, 2025 at 07:19:27AM -0700, Linus Torvalds wrote:
> On Fri, 4 Apr 2025 at 01:28, Christoph Hellwig <hch@infradead.org> wrote:
> >
> > Or just kill the non-scoped guard because it simply is an insane API.
>
> The scoped guard may be odd, but it's actually rather a common
> situation. And when used with the proper indentation, it also ends up
> being pretty visually clear about what part of a function is under the
> lock.
>
> But yeah, if you don't end up using it right, it ends up very very wrong.
>
> Not that that is any different from "if ()" or any other similar
> construct, but obviously people are much more *used* to 'if ()' and
> friends.
>
> An 'if ()" without the nested statement looks very wrong - although
> it's certainly not unheard of - while a 'scoped_guard()' without the
> nested statement might visually pass just because it doesn't trigger
> the same visceral "that's not right" reaction.
>
> So I don't think it's an insane API, I think it's mostly that it's a
> _newish_ API.

Both the scoped and non-scoped guards are very useful. I initially used
a scoped variant but then reworked the code to use a non-scoped one and
fscked it up.

I agree with Linus here it was just me not having the same "Oh right,
that's odd reaction.".

I love the guard infrastructure. It's a massive improvement. Thanks to
Peter for finally bringing this into the kernel after I've worked with
this for years in userspace already. It literally helped obliterate
nearly all memory safety bugs in systemd and I'm confident it will have
positive effects in the kernel long-term as well.

And please, can we (collective we) for once all decide to not turn yet
another issue into a two week thread of New York Times Opinion pieces on
how Things Really Are and Should Have Been Done. :)