]> git.ipfire.org Git - thirdparty/linux.git/commit
make commit_tree() usable in same-namespace move case
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 26 Apr 2025 02:34:33 +0000 (22:34 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 29 Jun 2025 22:13:41 +0000 (18:13 -0400)
commit7c6fb47b2b6c1ffcb1cae9372b9fcf269444487a
tree6370ced5d5b92ecf76315513530a76b13efc7334
parentf0d0ba19985d23a3e83d654318ccb6e9c5f1b095
make commit_tree() usable in same-namespace move case

Once attach_recursive_mnt() has created all copies of original subtree,
it needs to put them in place(s).

Steps needed for those are slightly different:
1) in 'move' case, original copy doesn't need any rbtree
manipulations (everything's already in the same namespace where it will
be), but it needs to be detached from the current location
2) in 'attach' case, original may be in anon namespace; if it is,
all those mounts need to removed from their current namespace before
insertion into the target one
3) additional copies have a couple of extra twists - in case
of cross-userns propagation we need to lock everything other the root of
subtree and in case when we end up inserting under an existing mount,
that mount needs to be found (for original copy we have it explicitly
passed by the caller).

Quite a bit of that can be unified; as the first step, make commit_tree()
helper (inserting mounts into namespace, hashing the root of subtree
and marking the namespace as updated) usable in all cases; (2) and (3)
are already using it and for (1) we only need to make the insertion of
mounts into namespace conditional.

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