[CRIU] [PATCH 1/4] mount: don't add a separate entry for each enabled file systems
Andrey Vagin
avagin at openvz.org
Thu Apr 14 15:19:53 PDT 2016
From: Andrew Vagin <avagin at virtuozzo.com>
It isn't required and we will not have a limit for enabled file systems.
Cc: Oleg Nesterov <oleg at redhat.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
criu/include/mount.h | 1 +
criu/mount.c | 37 ++++++++++++++++++++-----------------
criu/proc_parse.c | 4 ++++
3 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/criu/include/mount.h b/criu/include/mount.h
index b3bbdce..59e7f9a 100644
--- a/criu/include/mount.h
+++ b/criu/include/mount.h
@@ -56,6 +56,7 @@ struct mount_info {
struct fstype *fstype;
char *source;
char *options;
+ char *fsname;
union {
bool mounted;
bool dumped;
diff --git a/criu/mount.c b/criu/mount.c
index b829ae5..f57b10c 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -1679,11 +1679,14 @@ static int always_fail(struct mount_info *pm)
return -1;
}
-static struct fstype fstypes[32] = {
+static struct fstype fstypes[] = {
{
.name = "unsupported",
.code = FSTYPE__UNSUPPORTED,
}, {
+ .name = "auto_cr",
+ .code = FSTYPE__AUTO,
+ }, {
.name = "proc",
.code = FSTYPE__PROC,
}, {
@@ -1825,21 +1828,12 @@ static struct fstype *__find_fstype_by_name(char *fst, bool force_auto)
for (i = 1; i < ARRAY_SIZE(fstypes); i++) {
struct fstype *fstype = fstypes + i;
- if (!fstype->name) {
- if (!force_auto && !fsname_is_auto(fst))
- break;
-
- fstype->name = xstrdup(fst);
- fstype->code = FSTYPE__AUTO;
- return fstype;
- }
-
if (!strcmp(fstype->name, fst))
return fstype;
}
- if (i == ARRAY_SIZE(fstypes)) /* ensure we have a room for auto */
- pr_err_once("fstypes[] overflow!\n");
+ if (force_auto || fsname_is_auto(fst))
+ return &fstypes[1];
return &fstypes[0];
}
@@ -1853,9 +1847,6 @@ static struct fstype *decode_fstype(u32 fst, char *fsname)
{
int i;
- if (fst == FSTYPE__AUTO)
- return __find_fstype_by_name(fsname, true);
-
if (fst == FSTYPE__UNSUPPORTED)
goto uns;
@@ -1882,7 +1873,7 @@ static int dump_one_mountpoint(struct mount_info *pm, struct cr_img *img)
me.fstype = pm->fstype->code;
if (me.fstype == FSTYPE__AUTO)
- me.fsname = pm->fstype->name;
+ me.fsname = pm->fsname;
if (pm->parent && !pm->dumped && !pm->need_plugin && !pm->external &&
pm->fstype->dump && fsroot_mounted(pm)) {
@@ -2288,6 +2279,7 @@ static int do_new_mount(struct mount_info *mi)
struct fstype *tp = mi->fstype;
bool remount_ro = (tp->restore && mi->sb_flags & MS_RDONLY);
mount_fn_t do_mount = (tp->mount) ? tp->mount : do_simple_mount;
+ char *fsname;
src = resolve_source(mi);
if (!src)
@@ -2302,7 +2294,12 @@ static int do_new_mount(struct mount_info *mi)
if (remount_ro)
sflags &= ~MS_RDONLY;
- if (do_mount(mi, src, tp->name, sflags) < 0) {
+ if (mi->fsname)
+ fsname = mi->fsname;
+ else
+ fsname = tp->name;
+
+ if (do_mount(mi, src, fsname, sflags) < 0) {
pr_perror("Can't mount at %s", mi->mountpoint);
return -1;
}
@@ -2739,6 +2736,7 @@ void mnt_entry_free(struct mount_info *mi)
xfree(mi->mountpoint);
xfree(mi->source);
xfree(mi->options);
+ xfree(mi->fsname);
xfree(mi);
}
}
@@ -2951,6 +2949,11 @@ static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
/* FIXME: abort unsupported early */
pm->fstype = decode_fstype(me->fstype, me->fsname);
+ if (me->fsname) {
+ pm->fsname = xstrdup(me->fsname);
+ if (!pm->fsname)
+ goto err;
+ }
if (get_mp_root(me, pm))
goto err;
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index 4522ce6..2dd8dc4 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -1277,6 +1277,10 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
cure_path(new->source);
+ new->fsname = xstrdup(*fsname);
+ if (!new->fsname)
+ goto err;
+
/*
* The kernel reports "subtypes" sometimes and the valid
* type-vs-subtype delimiter is the dot symbol. We disregard
--
2.5.0
More information about the CRIU
mailing list