add locked_recursive_removal()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 9 May 2024 20:32:51 +0000 (16:32 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 3 Jul 2025 02:36:27 +0000 (22:36 -0400)
commit9fd45235fdd2c2615a03c86ebe5a88b050dc5680
tree0d4e783064cca8a790fb8b868a5fa39a779adebb
parent2a8061ee5e41034eb14170ec4517b5583dbeff9f
add locked_recursive_removal()

simple_recursive_removal() assumes that parent is not locked and
locks it when it finally gets to removing the victim itself.
Usually that's what we want, but there are places where the
parent is *already* locked and we need it to stay that way.
In those cases simple_recursive_removal() would, of course,
deadlock, so we have to play racy games with unlocking/relocking
the parent around the call or open-code the entire thing.

A better solution is to provide a variant that expects to
be called with the parent already locked by the caller.
Parent should be locked with I_MUTEX_PARENT, to avoid false
positives from lockdep.

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