[CRIU] Re: [PATCH] restore: Order file restoring by their type
Pavel Emelyanov
xemul at parallels.com
Sat Apr 28 09:52:35 EDT 2012
On 04/28/2012 05:36 PM, Cyrill Gorcunov wrote:
> We need the files being restored in order of their
> type. In particular when we restore eventpoll file
> we expect every file descriptor the epoll watches on
> is already created and opened.
I'd explicitly restore only eventpoll files at the very
end instead.
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> files.c | 27 +++++++++++++++++++--------
> include/crtools.h | 2 +-
> 2 files changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/files.c b/files.c
> index 2fd4ec0..b5e7508 100644
> --- a/files.c
> +++ b/files.c
> @@ -373,9 +373,11 @@ static int collect_fd(int pid, struct fdinfo_entry *e, struct list_head *fds)
> int prepare_fd_pid(int pid, struct rst_info *rst_info)
> {
> int fdinfo_fd, ret = 0;
> + unsigned int i;
> u32 type = 0;
>
> - INIT_LIST_HEAD(&rst_info->fds);
> + for (i = 0; i < ARRAY_SIZE(rst_info->fds); i++)
> + INIT_LIST_HEAD(&rst_info->fds[i]);
>
> fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid);
> if (fdinfo_fd < 0) {
> @@ -391,8 +393,14 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info)
> ret = read_img_eof(fdinfo_fd, &e);
> if (ret <= 0)
> break;
> + if (e.type >= FD_INFO_MAX) {
> + ret = -1;
> + pr_err("Unexpected file type found %d [%#x]\n",
> + e.fd, e.type);
> + break;
> + }
>
> - ret = collect_fd(pid, &e, &rst_info->fds);
> + ret = collect_fd(pid, &e, &rst_info->fds[e.type]);
> if (ret < 0)
> break;
> }
> @@ -648,18 +656,21 @@ static int open_fdinfo(int pid, struct fdinfo_entry *fe, int state)
> int prepare_fds(struct pstree_item *me)
> {
> u32 type = 0, ret;
> - int state;
> + int state, i;
> struct fdinfo_list_entry *fle;
> int nr = 0;
>
> pr_info("%d: Opening fdinfo-s\n", me->pid);
>
> - for (state = 0; state < FD_STATE_MAX; state++)
> - list_for_each_entry(fle, &me->rst->fds, ps_list) {
> - ret = open_fdinfo(me->pid, &fle->fe, state);
> - if (ret)
> - goto done;
> + for (state = 0; state < FD_STATE_MAX; state++) {
> + for (i = 0; i < (int)ARRAY_SIZE(me->rst->fds); i++) {
> + list_for_each_entry(fle, &me->rst->fds[i], ps_list) {
> + ret = open_fdinfo(me->pid, &fle->fe, state);
> + if (ret)
> + goto done;
> + }
> }
> + }
>
> ret = run_unix_connections();
> done:
> diff --git a/include/crtools.h b/include/crtools.h
> index 291c880..99bd69f 100644
> --- a/include/crtools.h
> +++ b/include/crtools.h
> @@ -193,7 +193,7 @@ struct vma_area {
> #define vma_area_len(vma_area) vma_entry_len(&((vma_area)->vma))
>
> struct rst_info {
> - struct list_head fds;
> + struct list_head fds[FD_INFO_MAX];
> };
>
> struct pstree_item {
More information about the CRIU
mailing list