mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
mount: make general place for shared variables on mount-info on restore
Put remounted_rw to it. This allows us to easily add some more of such
variables without allocating each one of them separately.
Due to existance of shfree_last shmalloc'ed region can be inherited from
the previous caller so it needs to be explicitly zero initialized.
Fixes: 0a2d380e6
("ghost/mount: allocate remounted_rw in shmem to get
info from other processes")
Cherry-picked from Virtuozzo criu:
https://src.openvz.org/projects/OVZ/repos/criu/commits/6750e5793
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
0c41c1187b
commit
7a67949e55
@@ -26,6 +26,10 @@ struct ns_id;
|
||||
*/
|
||||
#define REMOUNTED_RW_SERVICE 2
|
||||
|
||||
struct rst_mount_info {
|
||||
int remounted_rw;
|
||||
};
|
||||
|
||||
struct mount_info {
|
||||
int mnt_id;
|
||||
int parent_mnt_id;
|
||||
@@ -86,7 +90,8 @@ struct mount_info {
|
||||
struct list_head postpone;
|
||||
|
||||
int is_overmounted;
|
||||
int *remounted_rw;
|
||||
|
||||
struct rst_mount_info *rmi;
|
||||
|
||||
void *private; /* associated filesystem data */
|
||||
};
|
||||
|
13
criu/mount.c
13
criu/mount.c
@@ -2955,11 +2955,12 @@ struct mount_info *mnt_entry_alloc(bool rst)
|
||||
new = xzalloc(sizeof(struct mount_info));
|
||||
if (new) {
|
||||
if (rst) {
|
||||
new->remounted_rw = shmalloc(sizeof(int));
|
||||
if (!new->remounted_rw) {
|
||||
new->rmi = shmalloc(sizeof(struct rst_mount_info));
|
||||
if (!new->rmi) {
|
||||
xfree(new);
|
||||
return NULL;
|
||||
}
|
||||
memset(new->rmi, 0, sizeof(struct rst_mount_info));
|
||||
}
|
||||
new->fd = -1;
|
||||
new->is_overmounted = -1;
|
||||
@@ -4073,9 +4074,9 @@ int try_remount_writable(struct mount_info *mi, bool ns)
|
||||
remounted = REMOUNTED_RW_SERVICE;
|
||||
|
||||
/* All mounts in mntinfo list should have it on restore */
|
||||
BUG_ON(mi->remounted_rw == NULL);
|
||||
BUG_ON(mi->rmi == NULL);
|
||||
|
||||
if (mi->flags & MS_RDONLY && !(*mi->remounted_rw & remounted)) {
|
||||
if (mi->flags & MS_RDONLY && !(mi->rmi->remounted_rw & remounted)) {
|
||||
if (mnt_is_overmounted(mi)) {
|
||||
pr_err("The mount %d is overmounted so paths are invisible\n", mi->mnt_id);
|
||||
return -1;
|
||||
@@ -4098,7 +4099,7 @@ int try_remount_writable(struct mount_info *mi, bool ns)
|
||||
if (call_helper_process(ns_remount_writable, mi))
|
||||
return -1;
|
||||
}
|
||||
*mi->remounted_rw |= remounted;
|
||||
mi->rmi->remounted_rw |= remounted;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -4113,7 +4114,7 @@ static int __remount_readonly_mounts(struct ns_id *ns)
|
||||
if (ns && mi->nsid != ns)
|
||||
continue;
|
||||
|
||||
if (!(*mi->remounted_rw & REMOUNTED_RW))
|
||||
if (!(mi->rmi->remounted_rw & REMOUNTED_RW))
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user