2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-01 06:45:35 +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:
Pavel Tikhomirov
2020-06-16 16:19:42 +03:00
committed by Andrei Vagin
parent 0c41c1187b
commit 7a67949e55
2 changed files with 13 additions and 7 deletions

View File

@@ -26,6 +26,10 @@ struct ns_id;
*/ */
#define REMOUNTED_RW_SERVICE 2 #define REMOUNTED_RW_SERVICE 2
struct rst_mount_info {
int remounted_rw;
};
struct mount_info { struct mount_info {
int mnt_id; int mnt_id;
int parent_mnt_id; int parent_mnt_id;
@@ -86,7 +90,8 @@ struct mount_info {
struct list_head postpone; struct list_head postpone;
int is_overmounted; int is_overmounted;
int *remounted_rw;
struct rst_mount_info *rmi;
void *private; /* associated filesystem data */ void *private; /* associated filesystem data */
}; };

View File

@@ -2955,11 +2955,12 @@ struct mount_info *mnt_entry_alloc(bool rst)
new = xzalloc(sizeof(struct mount_info)); new = xzalloc(sizeof(struct mount_info));
if (new) { if (new) {
if (rst) { if (rst) {
new->remounted_rw = shmalloc(sizeof(int)); new->rmi = shmalloc(sizeof(struct rst_mount_info));
if (!new->remounted_rw) { if (!new->rmi) {
xfree(new); xfree(new);
return NULL; return NULL;
} }
memset(new->rmi, 0, sizeof(struct rst_mount_info));
} }
new->fd = -1; new->fd = -1;
new->is_overmounted = -1; new->is_overmounted = -1;
@@ -4073,9 +4074,9 @@ int try_remount_writable(struct mount_info *mi, bool ns)
remounted = REMOUNTED_RW_SERVICE; remounted = REMOUNTED_RW_SERVICE;
/* All mounts in mntinfo list should have it on restore */ /* 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)) { if (mnt_is_overmounted(mi)) {
pr_err("The mount %d is overmounted so paths are invisible\n", mi->mnt_id); pr_err("The mount %d is overmounted so paths are invisible\n", mi->mnt_id);
return -1; return -1;
@@ -4098,7 +4099,7 @@ int try_remount_writable(struct mount_info *mi, bool ns)
if (call_helper_process(ns_remount_writable, mi)) if (call_helper_process(ns_remount_writable, mi))
return -1; return -1;
} }
*mi->remounted_rw |= remounted; mi->rmi->remounted_rw |= remounted;
} }
return 0; return 0;
@@ -4113,7 +4114,7 @@ static int __remount_readonly_mounts(struct ns_id *ns)
if (ns && mi->nsid != ns) if (ns && mi->nsid != ns)
continue; continue;
if (!(*mi->remounted_rw & REMOUNTED_RW)) if (!(mi->rmi->remounted_rw & REMOUNTED_RW))
continue; continue;
/* /*