[Devel] [PATCH VZ10 2/8] ve/mount: thread owning ve through alloc_vfsmnt/clone_mnt/copy_tree

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 14 17:50:38 MSK 2026


On 4/29/26 15:41, Pavel Tikhomirov wrote:
> Add owner_ve parameter to alloc_vfsmnt(), clone_mnt() and copy_tree(),
> to identify correct ownership of mount for accounting. NULL preserves
> the existing behaviour of taking current ve via get_exec_env().
> 
> 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.

s/were/where

> 
> There is no change in behaviour yet: copy_mnt_ns() still resolves the
> owner from current ve via get_exec_env().
> 
...

> @@ -1325,13 +1325,13 @@ vfs_submount(const struct dentry *mountpoint, struct file_system_type *type,
>   EXPORT_SYMBOL_GPL(vfs_submount);
>   
>   static struct mount *clone_mnt(struct mount *old, struct dentry *root,
> -					int flag)
> +				int flag, struct ve_struct *owner_ve)

So here we add an extra argument ve_struct without CONFIG_VE guard.

>   {
>   	struct super_block *sb = old->mnt.mnt_sb;
>   	struct mount *mnt;
>   	int err;
>   
> -	mnt = alloc_vfsmnt(old->mnt_devname);
> +	mnt = alloc_vfsmnt(old->mnt_devname, owner_ve);
>   	if (!mnt)
>   		return ERR_PTR(-ENOMEM);
>   
...

>   
> @@ -4235,7 +4238,11 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
>   	copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;
>   	if (user_ns != ns->user_ns)
>   		copy_flags |= CL_SHARED_TO_SLAVE;
> -	new = copy_tree(old, old->mnt.mnt_root, copy_flags);
> +#ifdef CONFIG_VE
> +	new = copy_tree(old, old->mnt.mnt_root, copy_flags, new_ns->ve_owner);
> +#else
> +	new = copy_tree(old, old->mnt.mnt_root, copy_flags, NULL);
> +#endif

but here we try to play more fair and use ve_owner only in case CONFIG_VE is used.
i understand that it's because we have added ve_owner in struct mnt_namespace under CONFIG_VE only.

But may be to add ve_owner unconditionally and set to non-NULL only in case of CONFIG_VE?
Then here we'll have just
+	new = copy_tree(old, old->mnt.mnt_root, copy_flags, new_ns->ve_owner);


>   	if (IS_ERR(new)) {
>   		namespace_unlock();
>   		ns_free_inum(&new_ns->ns);


More information about the Devel mailing list