Commit 38dd47b5 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

mount: Verify for external shared mount

If we meet shared mount point without share master belonging
to us -- it means we might fail on restore, thus require both
master/slave mount peers to be collected on dump.

In other words, the output will be like

 | (00.077025) Error (mount.c:421): Mount 49 (master_id: 2 shared_id: 0) has unreachable sharing
 | (00.077123) Error (mount.c:472): Can't proceed 4237's mountinfo
 | (00.077865) Error (namespaces.c:442): Namespaces dumping finished with error 65280

https://bugzilla.openvz.org/show_bug.cgi?id=2608Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e9b00f99
...@@ -395,6 +395,36 @@ static inline int is_root_mount(struct mount_info *mi) ...@@ -395,6 +395,36 @@ static inline int is_root_mount(struct mount_info *mi)
return is_root(mi->mountpoint); return is_root(mi->mountpoint);
} }
static int validate_shared(struct mount_info *info)
{
struct mount_info *m, *t;
/*
* If we have a shared mounts, both master
* slave targets are to be present in mount
* list, otherwise we can't be sure if we can
* recreate the scheme later on restore.
*/
for (m = info; m; m = m->next) {
if (!m->master_id)
continue;
for (t = info; t; t = t->next) {
if (t->shared_id == m->master_id)
break;
}
if (t)
continue;
pr_err("Mount %d (master_id: %d shared_id: %d) "
"has unreachable sharing\n", m->mnt_id,
m->master_id, m->shared_id);
return -1;
}
return 0;
}
static int dump_one_mountpoint(struct mount_info *pm, int fd) static int dump_one_mountpoint(struct mount_info *pm, int fd)
{ {
MntEntry me = MNT_ENTRY__INIT; MntEntry me = MNT_ENTRY__INIT;
...@@ -438,6 +468,11 @@ int dump_mnt_ns(int ns_pid, struct cr_fdset *fdset) ...@@ -438,6 +468,11 @@ int dump_mnt_ns(int ns_pid, struct cr_fdset *fdset)
return -1; return -1;
} }
if (validate_shared(mntinfo)) {
pr_err("Can't proceed %d's mountinfo\n", ns_pid);
return -1;
}
pr_info("Dumping mountpoints\n"); pr_info("Dumping mountpoints\n");
img_fd = fdset_fd(fdset, CR_FD_MOUNTPOINTS); img_fd = fdset_fd(fdset, CR_FD_MOUNTPOINTS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment