[CRIU] [PATCH 2/3] mount: dump one file system only once (v2)

Andrey Vagin avagin at openvz.org
Mon Jun 16 07:40:04 PDT 2014


A file system can be bind-mounted a few times and some of these mounts
can be non-root. We need to find one of root mounts and dump it.

v2: don't forget to check pm->dumped and pm->parent
    don't dump a root file system, it's always external for now.

Reported-by: Saied Kazemi <saied at google.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/proc_parse.h |  5 ++++-
 mount.c              | 13 +++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/proc_parse.h b/include/proc_parse.h
index 09c9efd..9400231 100644
--- a/include/proc_parse.h
+++ b/include/proc_parse.h
@@ -116,7 +116,10 @@ struct mount_info {
 	struct fstype	*fstype;
 	char		*source;
 	char		*options;
-	bool		mounted;
+	union {
+		bool		mounted;
+		bool		dumped;
+	};
 	bool		need_plugin;
 	int		is_file;
 	bool		is_ns_root;
diff --git a/mount.c b/mount.c
index b449502..2282c2b 100644
--- a/mount.c
+++ b/mount.c
@@ -863,8 +863,17 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
 			pm->root, pm->mountpoint);
 
 	me.fstype		= pm->fstype->code;
-	if (!pm->need_plugin && pm->fstype->dump && pm->fstype->dump(pm))
-		return -1;
+
+	if (pm->parent && !pm->dumped && !pm->need_plugin &&
+	    pm->fstype->dump && fsroot_mounted(pm)) {
+		struct mount_info *t;
+
+		if (pm->fstype->dump(pm))
+			return -1;
+
+		list_for_each_entry(t, &pm->mnt_bind, mnt_bind)
+			t->dumped = true;
+	}
 
 	me.mnt_id		= pm->mnt_id;
 	me.root_dev		= pm->s_dev;
-- 
1.8.5.3



More information about the CRIU mailing list