Skip to content

Commit 86cdbae

Browse files
committed
mnt: simplify ns_common_init() handling
Assign the reserved MNT_NS_ANON_INO sentinel to anonymous mount namespaces and cleanup the initial mount ns allocation. This is just a preparatory patch and the ns->inum check in ns_common_init() will be dropped in the next patch. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent cc47f43 commit 86cdbae

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

fs/namespace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4103,6 +4103,8 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a
41034103
return ERR_PTR(-ENOMEM);
41044104
}
41054105

4106+
if (anon)
4107+
new_ns->ns.inum = MNT_NS_ANON_INO;
41064108
ret = ns_common_init(&new_ns->ns, &mntns_operations, !anon);
41074109
if (ret) {
41084110
kfree(new_ns);

kernel/nscommon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
66
bool alloc_inum)
77
{
8-
if (alloc_inum) {
8+
if (alloc_inum && !ns->inum) {
99
int ret;
1010
ret = proc_alloc_inum(&ns->inum);
1111
if (ret)

0 commit comments

Comments
 (0)