[Devel] [PATCH rh7 v2 2/2] ve/fs/sync: fix CT's mountpoints traversal

Andrey Ryabinin aryabinin at virtuozzo.com
Thu Feb 25 01:00:18 PST 2016


Currently sync reads 've->root_path.mnt' mount and iterate over it childs.
This doesn't work, as not all in-container mounts could be reached that way.

This patch slightly rework's mounts traversal. Now sync just iterates over all
mounts of ve's mount namespace (actually we iterate over all mounts that
seen in container's /proc/mounts). This approach seems much more correct and
also simpler.

https://jira.sw.ru/browse/PSBM-44125

Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 fs/mount.h     | 1 -
 fs/namespace.c | 2 +-
 fs/sync.c      | 4 ++--
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/mount.h b/fs/mount.h
index b496064..013152b 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -71,7 +71,6 @@ static inline int is_mounted(struct vfsmount *mnt)
 }
 
 extern struct rw_semaphore namespace_sem;
-extern struct mount *next_mnt(struct mount *p, struct mount *root);
 
 extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
 
diff --git a/fs/namespace.c b/fs/namespace.c
index fa9ee9e..787619b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -756,7 +756,7 @@ static void commit_tree(struct mount *mnt)
 	touch_mnt_namespace(n);
 }
 
-struct mount *next_mnt(struct mount *p, struct mount *root)
+static struct mount *next_mnt(struct mount *p, struct mount *root)
 {
 	struct list_head *next = p->mnt_mounts.next;
 	if (next == &p->mnt_mounts) {
diff --git a/fs/sync.c b/fs/sync.c
index 0eb621f..e38331c 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -129,15 +129,15 @@ static int sync_filesystem_collected(struct list_head *sync_list, struct super_b
 
 static int sync_collect_filesystems(struct ve_struct *ve, struct list_head *sync_list)
 {
-	struct mount *root = real_mount(ve->root_path.mnt);
 	struct mount *mnt;
+	struct mnt_namespace *mnt_ns = ve->ve_ns->mnt_ns;
 	struct sync_sb *ss;
 	int ret = 0;
 
 	BUG_ON(!list_empty(sync_list));
 
 	down_read(&namespace_sem);
-	for (mnt = root; mnt; mnt = next_mnt(mnt, root)) {
+	list_for_each_entry(mnt, &mnt_ns->list, mnt_list) {
 		if (sync_filesystem_collected(sync_list, mnt->mnt.mnt_sb))
 			continue;
 
-- 
2.4.10



More information about the Devel mailing list