[CRIU] [PATCH v2 4/4] mount: Umount forced mounts on restore
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Jun 24 03:46:29 PDT 2016
Umount mountpoints, which was forced mounted at dump.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/mount.h | 1 +
criu/mount.c | 23 +++++++++++++++++++++++
images/mnt.proto | 1 +
3 files changed, 25 insertions(+)
diff --git a/criu/include/mount.h b/criu/include/mount.h
index bd15468..6a51cf2 100644
--- a/criu/include/mount.h
+++ b/criu/include/mount.h
@@ -70,6 +70,7 @@ struct mount_info {
struct ext_mount *external;
bool internal_sharing;
+ bool forced_mounted;
/* tree linkage */
struct mount_info *parent;
diff --git a/criu/mount.c b/criu/mount.c
index 7b13397..1c3c3d8 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1834,9 +1834,19 @@ static struct fstype *decode_fstype(u32 fst)
static int dump_one_fs(struct mount_info *mi)
{
struct mount_info *pm = mi;
+ struct forced_mount *fm;
struct mount_info *t;
bool first = true;
+ list_for_each_entry(fm, &forced_mounts_list, list) {
+ if (fm->mnt_id == mi->mnt_id &&
+ fm->ns_id == mi->nsid->kid) {
+ pr_info("Mark forced mount %u in ns %u\n", fm->mnt_id, fm->ns_id);
+ mi->forced_mounted = true;
+ break;
+ }
+ }
+
if (mi->is_ns_root || mi->need_plugin || mi->external || !mi->fstype->dump)
return 0;
@@ -1904,6 +1914,11 @@ static int dump_one_mountpoint(struct mount_info *pm, struct cr_img *img)
me.deleted = true;
}
+ if (pm->forced_mounted) {
+ me.forced_mounted = pm->forced_mounted;
+ me.has_forced_mounted = true;
+ }
+
if (pm->internal_sharing) {
me.has_internal_sharing = true;
me.internal_sharing = true;
@@ -2686,6 +2701,12 @@ static int do_mount_one(struct mount_info *mi)
mi->fstype = find_fstype_by_name("btrfs");
}
+ if (mi->forced_mounted) {
+ ret = umount(mi->mountpoint);
+ if (ret)
+ pr_perror("Can't umount %s\n", mi->mountpoint);
+ }
+
return ret;
}
@@ -3000,6 +3021,8 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
pm->is_ns_root = is_root(me->mountpoint);
if (me->has_internal_sharing)
pm->internal_sharing = me->internal_sharing;
+ if (me->has_forced_mounted)
+ pm->forced_mounted = me->forced_mounted;
pm->source = xstrdup(me->source);
if (!pm->source)
diff --git a/images/mnt.proto b/images/mnt.proto
index 9338ecb..4e56201 100644
--- a/images/mnt.proto
+++ b/images/mnt.proto
@@ -46,4 +46,5 @@ message mnt_entry {
optional bool deleted = 16;
optional uint32 sb_flags = 17 [(criu).hex = true];
+ optional bool forced_mounted = 18;
}
More information about the CRIU
mailing list