[Devel] [PATCH vz9 2/4] fs: introduce is_sb_ve_accessible()

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Wed Dec 8 18:29:38 MSK 2021


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>
---
 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; }
-- 
2.30.2



More information about the Devel mailing list