]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
fs/namespace.c: fix the namespace_sem guard mess
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 20 Aug 2025 23:05:21 +0000 (19:05 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 2 Sep 2025 23:35:56 +0000 (19:35 -0400)
commit360600f8ec635c3d47789ade3d3c120c88981343
tree776bed4318116dc26d1afb77bd92f67c9128f65e
parentb320789d6883cc00ac78ce83bccbfe7ed58afcf0
fs/namespace.c: fix the namespace_sem guard mess

If anything, namespace_lock should be DEFINE_LOCK_GUARD_0, not DEFINE_GUARD.
That way we
* do not need to feed it a bogus argument
* do not get gcc trying to compare an address of static in
file variable with -4097 - and, if we are unlucky, trying to keep
it in a register, with spills and all such.

The same problems apply to grabbing namespace_sem shared.

Rename it to namespace_excl, add namespace_shared, convert the existing users:

    guard(namespace_lock, &namespace_sem) => guard(namespace_excl)()
    guard(rwsem_read, &namespace_sem) => guard(namespace_shared)()
    scoped_guard(namespace_lock, &namespace_sem) => scoped_guard(namespace_excl)
    scoped_guard(rwsem_read, &namespace_sem) => scoped_guard(namespace_shared)

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c