[CRIU] [PATCH 1/7] mount: remove useless check in populate_mnt_ns

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Feb 7 15:17:48 MSK 2019


The path:

restore_root_task
 prepare_namespace_before_tasks
  mntns_maybe_create_roots

is always called before the path below:

retore_root_task
 fork_with_pid
  restore_task_with_children
   prepare_namespace
    prepare_mnt_ns
     populate_mnt_ns

So (!!mnt_roots) == (root_ns_mask & CLONE_NEWNS) in populate_mnt_ns, but
in prepare_mnt_ns we've already checked that it is true, so there is no
need in these check - remove it.

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/mount.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/criu/mount.c b/criu/mount.c
index c842edb47..7e2db60a9 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -3140,15 +3140,12 @@ static int populate_mnt_ns(void)
 	struct ns_id *nsid;
 	int ret;
 
-	if (mnt_roots) {
-		/* mnt_roots is a tmpfs mount and it's private */
-		root_yard_mp = mnt_entry_alloc();
-		if (!root_yard_mp)
-			return -1;
+	root_yard_mp = mnt_entry_alloc();
+	if (!root_yard_mp)
+		return -1;
 
-		root_yard_mp->mountpoint = mnt_roots;
-		root_yard_mp->mounted = true;
-	}
+	root_yard_mp->mountpoint = mnt_roots;
+	root_yard_mp->mounted = true;
 
 	pms = mnt_build_tree(mntinfo, root_yard_mp);
 	if (!pms)
-- 
2.20.1



More information about the CRIU mailing list