[CRIU] [PATCH v4 32/33] files: Merge collect_gen_fd() and collect_used_fd(), and call it unconditionally
Kirill Tkhai
ktkhai at virtuozzo.com
Tue Dec 13 07:08:56 PST 2016
Since we keep files of all types in a single list (fds), it's possible
to use only function for that and to call it unconditionally.
v4: New
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/autofs.c | 4 +---
criu/fifo.c | 1 -
criu/files-reg.c | 2 --
criu/files.c | 10 ++++++----
criu/include/files.h | 7 +------
5 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/criu/autofs.c b/criu/autofs.c
index 28b1bd2..33e5864 100644
--- a/criu/autofs.c
+++ b/criu/autofs.c
@@ -875,9 +875,7 @@ static int autofs_create_fle(struct pstree_item *task, FdinfoEntry *fe,
fle_init(le, task->pid.virt, fe);
- collect_gen_fd(le, rst_info);
-
- collect_used_fd(le, rst_info);
+ collect_task_fd(le, rst_info);
list_add_tail(&le->desc_list, &desc->fd_info_head);
le->desc = desc;
diff --git a/criu/fifo.c b/criu/fifo.c
index ebe2201..b545125 100644
--- a/criu/fifo.c
+++ b/criu/fifo.c
@@ -126,7 +126,6 @@ static void collect_fifo_fd(struct file_desc *d,
info = container_of(d, struct fifo_info, d);
info->reg_d = collect_special_file(info->fe->id);
BUG_ON(info->reg_d == NULL);
- collect_gen_fd(fle, ri);
}
static struct file_desc_ops fifo_desc_ops = {
diff --git a/criu/files-reg.c b/criu/files-reg.c
index 2f6a14b..f6bc092 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -1639,8 +1639,6 @@ static void collect_reg_fd(struct file_desc *fdesc,
{
if (list_empty(&fdesc->fd_info_head))
remap_get(fdesc, 'f');
-
- collect_gen_fd(fle, ri);
}
static int open_fe_fd(struct file_desc *fd, int *new_fd)
diff --git a/criu/files.c b/criu/files.c
index 0338c1b..bd7fe4f 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -112,10 +112,14 @@ struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd)
return NULL;
}
-void collect_used_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri)
+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) {
if (new_fle->fe->fd < fle->fe->fd)
break;
@@ -675,10 +679,8 @@ static int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
if (fdesc->ops->collect_fd)
fdesc->ops->collect_fd(fdesc, new_le, rst_info);
- else
- collect_gen_fd(new_le, rst_info);
- collect_used_fd(new_le, rst_info);
+ collect_task_fd(new_le, rst_info);
list_add_tail(&new_le->desc_list, &le->desc_list);
new_le->desc = fdesc;
diff --git a/criu/include/files.h b/criu/include/files.h
index 8af9b19..03b6bcc 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -122,12 +122,7 @@ struct file_desc_ops {
char * (*name)(struct file_desc *, char *b, size_t s);
};
-extern void collect_used_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri);
-
-static inline void collect_gen_fd(struct fdinfo_list_entry *fle, struct rst_info *ri)
-{
- list_add_tail(&fle->ps_list, &ri->fds);
-}
+void collect_task_fd(struct fdinfo_list_entry *new_fle, struct rst_info *ri);
unsigned int find_unused_fd(struct list_head *head, int hint_fd);
struct fdinfo_list_entry *find_used_fd(struct list_head *head, int fd);
More information about the CRIU
mailing list