[CRIU] [PATCH 1/2] mount: execute propagation logic for the root mount

Andrey Vagin avagin at openvz.org
Fri Mar 14 07:51:51 PDT 2014


The root mount isn't always private. For example it is mounted
as a slave in LXC 1.0 containers. So we need to execute logic
about propogation for the root mount too.

Reported-by: David Shwatrz <dshwatrz at gmail.com>
Cc: David Shwatrz <dshwatrz at gmail.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 mount.c | 42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

diff --git a/mount.c b/mount.c
index 522ae3c..669335d 100644
--- a/mount.c
+++ b/mount.c
@@ -425,7 +425,7 @@ static int collect_shared(struct mount_info *info)
 			}
 		}
 
-		if (need_master) {
+		if (need_master && m->parent) {
 			pr_err("Mount %d (master_id: %d shared_id: %d) "
 			       "has unreachable sharing\n", m->mnt_id,
 				m->master_id, m->shared_id);
@@ -994,11 +994,10 @@ static int propagate_siblings(struct mount_info *mi)
 	return 0;
 }
 
-static int propagate_mount(struct mount_info *mi)
+static void propagate_over_parents(struct mount_info *mi)
 {
 	struct mount_info *t;
 
-	propagate_siblings(mi);
 	umount_from_slaves(mi);
 
 	/* Propagate this mount to everyone from a parent group */
@@ -1007,14 +1006,24 @@ static int propagate_mount(struct mount_info *mi)
 		struct mount_info *c;
 
 		list_for_each_entry(c, &t->children, siblings) {
-			if (mounts_equal(mi, c, false)) {
-				pr_debug("\t\tPropogate %s\n", c->mountpoint);
-				c->mounted = true;
-				propagate_siblings(c);
-				umount_from_slaves(c);
-			}
+			if (!mounts_equal(mi, c, false))
+				continue;
+			pr_debug("\t\tPropogate %s\n", c->mountpoint);
+			c->mounted = true;
+			propagate_siblings(c);
+			umount_from_slaves(c);
 		}
 	}
+}
+
+static int propagate_mount(struct mount_info *mi)
+{
+	struct mount_info *t;
+
+	propagate_siblings(mi);
+
+	if (mi->parent)
+		propagate_over_parents(mi);
 
 	/*
 	 * FIXME Currently non-root mounts can be restored
@@ -1140,14 +1149,20 @@ static bool can_mount_now(struct mount_info *mi)
 
 static int do_mount_one(struct mount_info *mi)
 {
-	int ret;
-
-	if (!mi->parent)
-		return 0;
+	int ret = 0;
 
 	if (mi->mounted)
 		return 0;
 
+	if (!mi->parent) {
+		if (restore_shared_options(mi, !mi->shared_id && !mi->master_id,
+						mi->shared_id,
+						mi->master_id))
+			return -1;
+		mi->mounted = true;
+		goto out;
+	}
+
 	if (!can_mount_now(mi)) {
 		pr_debug("Postpone slave %s\n", mi->mountpoint);
 		return 1;
@@ -1160,6 +1175,7 @@ static int do_mount_one(struct mount_info *mi)
 	else
 		ret = do_bind_mount(mi);
 
+out:
 	if (ret == 0 && propagate_mount(mi))
 		return -1;
 
-- 
1.8.5.3



More information about the CRIU mailing list