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

Submitted by Pavel Tikhomirov on Feb. 7, 2019, 12:17 p.m.

Details

Message ID 20190207121754.19667-2-ptikhomirov@virtuozzo.com
State New
Series "mount: check mounts after restoring"
Headers show

Commit Message

Pavel Tikhomirov Feb. 7, 2019, 12:17 p.m.
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@virtuozzo.com>
---
 criu/mount.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

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)