[Devel,criu,2/3] mount: fix mounting non-root shared mounts

Submitted by Andrei Vagin on Nov. 22, 2016, 1:07 a.m.

Details

Message ID 1479776840-23544-2-git-send-email-avagin@openvz.org
State New
Series "Series without cover letter"
Headers show

Commit Message

Andrei Vagin Nov. 22, 2016, 1:07 a.m.
From: Andrei Vagin <avagin@openvz.org>

A widest mount of a shared group has to be mounted first and
then other mounts of this group has to be mounted from the first mount
to inherite the shared group.

https://jira.sw.ru/browse/PSBM-55494
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 criu/mount.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/mount.c b/criu/mount.c
index 76d1505..3a98e63 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -2444,7 +2444,9 @@  static int propagate_siblings(struct mount_info *mi)
 	 * to inherite shared group or master id
 	 */
 	list_for_each_entry(t, &mi->mnt_share, mnt_share) {
-		if (t->mounted || t->bind)
+		if (t->mounted)
+			continue;
+		if (t->bind && t->bind->shared_id == mi->shared_id)
 			continue;
 		pr_debug("\t\tBind share %s\n", t->mountpoint);
 		t->bind = mi;
@@ -2902,6 +2904,15 @@  static bool can_mount_now(struct mount_info *mi)
 	if (!fsroot_mounted(mi) && (mi->bind == NULL && !mi->need_plugin && !mi->external))
 		return false;
 
+	if (mi->bind && mi->shared_id != mi->bind->shared_id) {
+		struct mount_info *n;
+		int len;
+
+		len = strlen(mi->root);
+		list_for_each_entry(n, &mi->mnt_share, mnt_share)
+			if (len > strlen(n->root))
+				return false;
+	}
 shared:
 	if (mi->parent->shared_id) {
 		struct mount_info *p = mi->parent, *n;