2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 22:35:33 +00:00

files: Keep single sorted list of fds

After fds restore set merge we no longer need two lists.

Don't BUG in eventpoll when the tfd is not on the list.
This situation means that it's restored, so it's safe
to report OK from this place.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Pavel Emelyanov
2017-02-16 15:12:00 +03:00
parent de8fab2e0e
commit b43f3f54be
4 changed files with 14 additions and 16 deletions

View File

@@ -153,7 +153,7 @@ static int epoll_not_ready_tfd(EventpollTfdEntry *tdefe)
{
struct fdinfo_list_entry *fle;
list_for_each_entry(fle, &rsti(current)->used, used_list) {
list_for_each_entry(fle, &rsti(current)->fds, ps_list) {
if (tdefe->tfd != fle->fe->fd)
continue;
@@ -162,7 +162,11 @@ static int epoll_not_ready_tfd(EventpollTfdEntry *tdefe)
else
return (fle->stage != FLE_RESTORED);
}
BUG();
/*
* If tgt fle is not on the fds list, it's already
* restored (see open_fdinfos), so we're ready.
*/
return 0;
}

View File

@@ -103,8 +103,8 @@ struct fdinfo_list_entry *find_used_fd(struct pstree_item *task, int fd)
struct list_head *head;
struct fdinfo_list_entry *fle;
head = &rsti(task)->used;
list_for_each_entry_reverse(fle, head, used_list) {
head = &rsti(task)->fds;
list_for_each_entry_reverse(fle, head, ps_list) {
if (fle->fe->fd == fd)
return fle;
/* List is ordered, so let's stop */
@@ -118,16 +118,13 @@ void collect_task_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri)
{
struct fdinfo_list_entry *fle;
/* fles in fds list are disordered */
list_add_tail(&new_fle->ps_list, &ri->fds);
/* fles in used list are ordered by fd */
list_for_each_entry(fle, &ri->used, used_list) {
/* fles in fds list are ordered by fd */
list_for_each_entry(fle, &ri->fds, ps_list) {
if (new_fle->fe->fd < fle->fe->fd)
break;
}
list_add_tail(&new_fle->used_list, &fle->used_list);
list_add_tail(&new_fle->ps_list, &fle->ps_list);
}
unsigned int find_unused_fd(struct pstree_item *task, int hint_fd)
@@ -142,9 +139,9 @@ unsigned int find_unused_fd(struct pstree_item *task, int hint_fd)
}
prev_fd = service_fd_min_fd() - 1;
head = &rsti(task)->used;
head = &rsti(task)->fds;
list_for_each_entry_reverse(fle, head, used_list) {
list_for_each_entry_reverse(fle, head, ps_list) {
fd = fle->fe->fd;
if (prev_fd > fd) {
fd++;
@@ -788,7 +785,6 @@ int prepare_fd_pid(struct pstree_item *item)
pid_t pid = vpid(item);
struct rst_info *rst_info = rsti(item);
INIT_LIST_HEAD(&rst_info->used);
INIT_LIST_HEAD(&rst_info->fds);
if (item->ids == NULL) /* zombie */
@@ -876,7 +872,7 @@ static bool task_fle(struct pstree_item *task, struct fdinfo_list_entry *fle)
{
struct fdinfo_list_entry *tmp;
list_for_each_entry(tmp, &rsti(task)->used, used_list)
list_for_each_entry(tmp, &rsti(task)->fds, ps_list)
if (fle == tmp)
return true;
return false;

View File

@@ -74,7 +74,6 @@ struct fdinfo_list_entry {
struct list_head desc_list; /* To chain on @fd_info_head */
struct file_desc *desc; /* Associated file descriptor */
struct list_head ps_list; /* To chain per-task files */
struct list_head used_list; /* To chain per-task used fds */
int pid;
FdinfoEntry *fe;
u8 received:1;

View File

@@ -26,7 +26,6 @@ struct fdt {
struct _MmEntry;
struct rst_info {
struct list_head used;
struct list_head fds;
void *premmapped_addr;