[CRIU] [PATCH 1/2] mount: don't remount a slave mount as private when it isn't required

Andrey Vagin avagin at openvz.org
Mon Dec 14 06:46:14 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

We don't need to remount a mount as private, when a source mount and
a new mount has the same master_id and shared_id

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 mount.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mount.c b/mount.c
index e1608a9..964b26c 100644
--- a/mount.c
+++ b/mount.c
@@ -2277,7 +2277,8 @@ static int do_bind_mount(struct mount_info *mi)
 	bool force_private_remount = false;
 	unsigned long mflags;
 	int exit_code = -1;
-	bool shared = 0;
+	bool shared = false;
+	bool master = false;
 	char *mnt_path;
 	struct stat st;
 	bool umount_mnt_path = false;
@@ -2301,6 +2302,7 @@ static int do_bind_mount(struct mount_info *mi)
 	}
 
 	shared = mi->shared_id && mi->shared_id == mi->bind->shared_id;
+	master = mi->master_id && mi->master_id == mi->bind->master_id;
 	cut_root = cut_root_for_bind(mi->root, mi->bind->root);
 
 	if (list_empty(&mi->bind->children))
@@ -2374,9 +2376,9 @@ out:
 	 * shared - the mount is in the same shared group with mi->bind
 	 * mi->shared_id && !shared - create a new shared group
 	 */
-	if (restore_shared_options(mi, force_private_remount || (!shared && !mi->master_id),
+	if (restore_shared_options(mi, force_private_remount || (!shared && !master),
 					mi->shared_id && !shared,
-					mi->master_id))
+					mi->master_id && !master))
 		return -1;
 
 	mi->mounted = true;
-- 
2.4.3



More information about the CRIU mailing list