Commit 8f169802 authored by Pavel Emelyanov's avatar Pavel Emelyanov

restore: Prepare on-restorer aios earlier

Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 631dd827
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
#include <stdbool.h> #include <stdbool.h>
#include "vma.h" #include "vma.h"
#include "xmalloc.h" #include "xmalloc.h"
#include "pstree.h"
#include "restorer.h"
#include "aio.h" #include "aio.h"
#include "rst_info.h"
#include "rst-malloc.h"
#include "parasite.h" #include "parasite.h"
#include "parasite-syscall.h" #include "parasite-syscall.h"
#include "images/mm.pb-c.h" #include "images/mm.pb-c.h"
...@@ -117,3 +121,29 @@ int parasite_collect_aios(struct parasite_ctl *ctl, struct vm_area_list *vmas) ...@@ -117,3 +121,29 @@ int parasite_collect_aios(struct parasite_ctl *ctl, struct vm_area_list *vmas)
return 0; return 0;
} }
int prepare_aios(struct pstree_item *t, struct task_restore_args *ta)
{
int i;
MmEntry *mm = rsti(t)->mm;
/*
* Put info about AIO rings, they will get remapped
*/
ta->rings = (struct rst_aio_ring *)rst_mem_align_cpos(RM_PRIVATE);
ta->rings_n = mm->n_aios;
for (i = 0; i < mm->n_aios; i++) {
struct rst_aio_ring *raio;
raio = rst_mem_alloc(sizeof(*raio), RM_PRIVATE);
if (!raio)
return -1;
raio->addr = mm->aios[i]->id;
raio->nr_req = mm->aios[i]->nr_req;
raio->len = mm->aios[i]->ring_len;
}
return 0;
}
...@@ -508,6 +508,9 @@ static int restore_one_alive_task(int pid, CoreEntry *core) ...@@ -508,6 +508,9 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
if (prepare_vmas(current, ta)) if (prepare_vmas(current, ta))
return -1; return -1;
if (prepare_aios(current, ta))
return -1;
if (fixup_sysv_shmems()) if (fixup_sysv_shmems())
return -1; return -1;
...@@ -2668,10 +2671,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core) ...@@ -2668,10 +2671,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
#ifdef CONFIG_VDSO #ifdef CONFIG_VDSO
unsigned long vdso_rt_size = 0; unsigned long vdso_rt_size = 0;
#endif #endif
unsigned long aio_rings;
MmEntry *mm = rsti(current)->mm;
int n_seccomp_filters = 0; int n_seccomp_filters = 0;
unsigned long seccomp_filter_pos = 0; unsigned long seccomp_filter_pos = 0;
...@@ -2689,23 +2688,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core) ...@@ -2689,23 +2688,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
BUILD_BUG_ON(sizeof(struct task_restore_args) & 1); BUILD_BUG_ON(sizeof(struct task_restore_args) & 1);
BUILD_BUG_ON(sizeof(struct thread_restore_args) & 1); BUILD_BUG_ON(sizeof(struct thread_restore_args) & 1);
/*
* Put info about AIO rings, they will get remapped
*/
aio_rings = rst_mem_align_cpos(RM_PRIVATE);
for (i = 0; i < mm->n_aios; i++) {
struct rst_aio_ring *raio;
raio = rst_mem_alloc(sizeof(*raio), RM_PRIVATE);
if (!raio)
goto err_nv;
raio->addr = mm->aios[i]->id;
raio->nr_req = mm->aios[i]->nr_req;
raio->len = mm->aios[i]->ring_len;
}
/* /*
* Get all the tcp sockets fds into rst memory -- restorer * Get all the tcp sockets fds into rst memory -- restorer
* will turn repair off before going sigreturn * will turn repair off before going sigreturn
...@@ -2847,6 +2829,7 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core) ...@@ -2847,6 +2829,7 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
task_args->task_size = kdat.task_size; task_args->task_size = kdat.task_size;
task_args->vmas = rst_mem_remap_ptr((unsigned long)task_args->vmas, RM_PRIVATE); task_args->vmas = rst_mem_remap_ptr((unsigned long)task_args->vmas, RM_PRIVATE);
task_args->rings = rst_mem_remap_ptr((unsigned long)task_args->rings, RM_PRIVATE);
#define remap_array(name, nr, cpos) do { \ #define remap_array(name, nr, cpos) do { \
task_args->name##_n = nr; \ task_args->name##_n = nr; \
...@@ -2857,7 +2840,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core) ...@@ -2857,7 +2840,6 @@ static int sigreturn_restore(pid_t pid, unsigned long ta_cp, CoreEntry *core)
remap_array(timerfd, rst_timerfd_nr, rst_timerfd_cpos); remap_array(timerfd, rst_timerfd_nr, rst_timerfd_cpos);
remap_array(siginfo, siginfo_nr, siginfo_cpos); remap_array(siginfo, siginfo_nr, siginfo_cpos);
remap_array(tcp_socks, rst_tcp_socks_nr, rst_tcp_socks_cpos); remap_array(tcp_socks, rst_tcp_socks_nr, rst_tcp_socks_cpos);
remap_array(rings, mm->n_aios, aio_rings);
remap_array(rlims, rlims_nr, rlims_cpos); remap_array(rlims, rlims_nr, rlims_cpos);
remap_array(helpers, n_helpers, helpers_pos); remap_array(helpers, n_helpers, helpers_pos);
remap_array(zombies, n_zombies, zombies_pos); remap_array(zombies, n_zombies, zombies_pos);
......
...@@ -9,6 +9,8 @@ void free_aios(MmEntry *mme); ...@@ -9,6 +9,8 @@ void free_aios(MmEntry *mme);
struct parasite_ctl; struct parasite_ctl;
int parasite_collect_aios(struct parasite_ctl *, struct vm_area_list *); int parasite_collect_aios(struct parasite_ctl *, struct vm_area_list *);
unsigned long aio_rings_args_size(struct vm_area_list *); unsigned long aio_rings_args_size(struct vm_area_list *);
struct task_restore_args;
int prepare_aios(struct pstree_item *t, struct task_restore_args *ta);
struct aio_ring { struct aio_ring {
unsigned id; /* kernel internal index number */ unsigned id; /* kernel internal index number */
......
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