[Devel] [PATCH RHEL7 COMMIT] ve/fs/sync: fix CT's mountpoints traversal

Konstantin Khorenko khorenko at virtuozzo.com
Fri Feb 26 05:02:40 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.3.1-vz7.10.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.3.1.vz7.10.13
------>
commit 9f99b6e78e352c6ac5362b29a011a4a5e6d24d05
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Fri Feb 26 17:02:40 2016 +0400

    ve/fs/sync: fix CT's mountpoints traversal
    
    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>
    
    Note: this patch does not cover traversing sub mount namespaces
    and we are ok with that for now.
    https://jira.sw.ru/browse/PSBM-44684
    
    Reviewed-by: Vladimir Davydov <vdavydov 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;
 


More information about the Devel mailing list