[Devel] [PATCH VZ10 1/8] ve/mntns: add ve_owner to struct mnt_namespace
Vasileios Almpanis
vasileios.almpanis at virtuozzo.com
Thu Apr 30 11:02:23 MSK 2026
Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
On 4/29/26 3:41 PM, Pavel Tikhomirov wrote:
> Introduce a ve_owner field on struct mnt_namespace pointing at the ve
> that owns the namespace.
>
> This will be used to derive correct ownership of newly created mounts in
> case of simultaneous creation of new ve namespace and mount namespace,
> were we would like new mounts to have the new ve as an owner.
>
> There is no change in behaviour yet: alloc_mnt_ns() still resolves the
> owner from current ve via get_exec_env().
>
> To ensure the pointer is valid, alloc_mnt_ns takes and free_mnt_ns()
> drops the reference.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-129744
> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
> Feature: ve: ve generic structures
> ---
> fs/mount.h | 6 ++++++
> fs/namespace.c | 8 ++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/fs/mount.h b/fs/mount.h
> index 8e8fa47f54fd..dd1ef7e40639 100644
> --- a/fs/mount.h
> +++ b/fs/mount.h
> @@ -4,6 +4,9 @@
> #include <linux/poll.h>
> #include <linux/ns_common.h>
> #include <linux/fs_pin.h>
> +#ifdef CONFIG_VE
> +#include <linux/ve.h>
> +#endif
>
> struct mnt_namespace {
> struct ns_common ns;
> @@ -19,6 +22,9 @@ struct mnt_namespace {
> struct rb_node mnt_ns_tree_node; /* node in the mnt_ns_tree */
> refcount_t passive; /* number references not pinning @mounts */
> struct list_head mntns_list;
> +#ifdef CONFIG_VE
> + struct ve_struct *ve_owner;
> +#endif
> } __randomize_layout;
>
> struct mnt_pcp {
> diff --git a/fs/namespace.c b/fs/namespace.c
> index d18aaba94131..dd10ed5007ea 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -4143,6 +4143,11 @@ static void free_mnt_ns(struct mnt_namespace *ns)
> list_del(&ns->mntns_list);
> spin_unlock(&all_mntns_list_lock);
>
> +#ifdef CONFIG_VE
> + if (ns->ve_owner)
> + put_ve(ns->ve_owner);
> +#endif
> +
> mnt_ns_tree_remove(ns);
> }
>
> @@ -4194,6 +4199,9 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a
> init_waitqueue_head(&new_ns->poll);
> new_ns->user_ns = get_user_ns(user_ns);
> new_ns->ucounts = ucounts;
> +#ifdef CONFIG_VE
> + new_ns->ve_owner = get_ve(get_exec_env());
> +#endif
> return new_ns;
> }
>
--
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.
More information about the Devel
mailing list