[CRIU] [PATCH 1/2] mount: handle tracefs more gracefully

Tycho Andersen tycho.andersen at canonical.com
Mon May 16 15:30:47 PDT 2016


See the comment for details, but basically tracefs is automounted by the
kernel, so we can just mount debugfs with MS_REC and get the right result.

v2: rebase on criu-dev
v3: don't use a new fstype->flags, just always set MS_REC in debugfs'
    ->parse

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
This is kind of similarly ugly to to a cgroup patch I sent earlier, where
we needed some filesystem specific code and checks in various parts of
mount.c. I somehow can't figure out a nicer way to do this, but I am
definitely open to suggestions.
---
 criu/mount.c      | 15 +++++++++++++++
 criu/proc_parse.c |  7 +++++++
 images/mnt.proto  |  1 +
 3 files changed, 23 insertions(+)

diff --git a/criu/mount.c b/criu/mount.c
index 6f47655..e85e5d9 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1679,6 +1679,17 @@ out:
 	return ret;
 }
 
+static int debugfs_parse(struct mount_info *pm)
+{
+	/* tracefs is automounted underneath debugfs sometimes, and the
+	 * kernel's overmounting protection prevents us from mounting debugfs
+	 * first without tracefs, so let's always mount debugfs MS_REC.
+	 */
+	pm->flags |= MS_REC;
+
+	return 0;
+}
+
 static int cgroup_parse(struct mount_info *pm)
 {
 	if (!(root_ns_mask & CLONE_NEWCGROUP))
@@ -1780,6 +1791,10 @@ static struct fstype fstypes[] = {
 	}, {
 		.name = "debugfs",
 		.code = FSTYPE__DEBUGFS,
+		.parse = debugfs_parse,
+	}, {
+		.name = "tracefs",
+		.code = FSTYPE__TRACEFS,
 	}, {
 		.name = "cgroup",
 		.code = FSTYPE__CGROUP,
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index cebf21c..db1d0af 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -1381,6 +1381,13 @@ struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool for_dump)
 			goto end;
 		}
 
+		if (new->fstype->code == FSTYPE__TRACEFS) {
+			pr_info("\tskipping tracefs mounted at %s\n", new->mountpoint + 1);
+			mnt_entry_free(new);
+			new = NULL;
+			goto end;
+		}
+
 		pr_info("\ttype %s source %s mnt_id %d s_dev %#x %s @ %s flags %#x options %s\n",
 				fsname, new->source,
 				new->mnt_id, new->s_dev, new->root, new->mountpoint,
diff --git a/images/mnt.proto b/images/mnt.proto
index fe1e4bb..9338ecb 100644
--- a/images/mnt.proto
+++ b/images/mnt.proto
@@ -20,6 +20,7 @@ enum fstype {
 	AUTO			= 16;
 	OVERLAYFS		= 17;
 	AUTOFS			= 18;
+	TRACEFS			= 19;
 };
 
 message mnt_entry {
-- 
2.7.4



More information about the CRIU mailing list