Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: use boolean to indicate anonymous mount namespace

Stop playing games with the namespace id and use a boolean instead:

* This will remove the special-casing we need to do everywhere for mount
namespaces.

* It will allow us to use asserts on the namespace id for initial
namespaces everywhere.

* It will allow us to put anonymous mount namespaces on the namespaces
trees in the future and thus make them available to statmount() and
listmount().

Link: https://patch.msgid.link/20251110-work-namespace-nstree-fixes-v1-10-e8a9264e0fb9@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+5 -3
+2 -1
fs/mount.h
··· 27 27 unsigned int nr_mounts; /* # of mounts in the namespace */ 28 28 unsigned int pending_mounts; 29 29 refcount_t passive; /* number references not pinning @mounts */ 30 + bool is_anon; 30 31 } __randomize_layout; 31 32 32 33 struct mnt_pcp { ··· 176 175 177 176 static inline bool is_anon_ns(struct mnt_namespace *ns) 178 177 { 179 - return ns->ns.ns_id == 0; 178 + return ns->is_anon; 180 179 } 181 180 182 181 static inline bool anon_ns_root(const struct mount *m)
+3 -2
fs/namespace.c
··· 4093 4093 dec_mnt_namespaces(ucounts); 4094 4094 return ERR_PTR(ret); 4095 4095 } 4096 - if (!anon) 4097 - ns_tree_gen_id(new_ns); 4096 + ns_tree_gen_id(new_ns); 4097 + 4098 + new_ns->is_anon = anon; 4098 4099 refcount_set(&new_ns->passive, 1); 4099 4100 new_ns->mounts = RB_ROOT; 4100 4101 init_waitqueue_head(&new_ns->poll);