[Devel] [PATCH vz9 3/5] fs: introduce is_sb_ve_accessible()
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Nov 22 10:58:57 MSK 2021
On 22.11.2021 09:20, Nikita Yushchenko wrote:
> This routine checks if any mount of the given superblock is accessible
> from VE, either from root or non-root mount namespace.
>
> To be used for per-VE sync implementation.
>
> https://jira.sw.ru/browse/PSBM-44684
> Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
> fs/internal.h | 10 ++++++++++
> fs/namespace.c | 17 +++++++++++++++++
> 2 files changed, 27 insertions(+)
>
> diff --git a/fs/internal.h b/fs/internal.h
> index 82e8eb32ff3d..257e51814d2c 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -96,6 +96,16 @@ int path_mount(const char *dev_name, struct path *path,
> const char *type_page, unsigned long flags, void *data_page);
> int path_umount(struct path *path, int flags);
>
> +#ifdef CONFIG_VE
> +extern bool is_sb_ve_accessible(struct ve_struct *ve, struct super_block *sb);
> +#else
> +static inline bool is_sb_ve_accessible(struct ve_struct *ve,
> + struct super_block *sb)
> +{
> + return true;
> +}
> +#endif
> +
> /*
> * fs_struct.c
> */
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 558fa26bde50..8dbda795b4db 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2832,6 +2832,23 @@ static inline void ve_mount_nr_dec(struct mount *mnt)
> mnt->ve_owner = NULL;
> }
>
> +bool is_sb_ve_accessible(struct ve_struct *ve, struct super_block *sb)
> +{
> + struct mount *mnt;
> + bool ret = false;
> +
> + lock_mount_hash();
> + list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
> + if (mnt->ve_owner == ve) {
> + ret = true;
> + break;
> + }
> + }
> + unlock_mount_hash();
> +
> + return ret;
> +}
> +
> #else /* CONFIG_VE */
>
> static inline int ve_mount_allowed(void) { return 1; }
>
More information about the Devel
mailing list