Commit a604c63c authored by Pavel Emelyanov's avatar Pavel Emelyanov

restore: Move type from file_desc to file_desc_ops

This saves some space on dynamic file_desc and makes file_desc_ops
looks closer to fdinfo_ops used on dump.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6a55c1c5
......@@ -140,6 +140,7 @@ err_close:
}
static struct file_desc_ops eventfd_desc_ops = {
.type = FDINFO_EVENTFD,
.open = eventfd_open,
};
......@@ -165,7 +166,7 @@ int collect_eventfd(void)
else if (!ret)
break;
pr_info_eventfd("Collected ", &info->efe);
file_desc_add(&info->d, FDINFO_EVENTFD, info->efe.id, &eventfd_desc_ops);
file_desc_add(&info->d, info->efe.id, &eventfd_desc_ops);
}
err:
......
......@@ -202,6 +202,7 @@ err_close:
}
static struct file_desc_ops desc_ops = {
.type = FDINFO_EVENTPOLL,
.open = eventpoll_open,
};
......@@ -253,7 +254,7 @@ int collect_eventpoll(void)
break;
pr_info_eventpoll("Collected ", &info->efe);
file_desc_add(&info->d, FDINFO_EVENTPOLL, info->efe.id, &desc_ops);
file_desc_add(&info->d, info->efe.id, &desc_ops);
}
err:
......
......@@ -46,10 +46,9 @@ int prepare_shared_fdinfo(void)
return 0;
}
void file_desc_add(struct file_desc *d, int type, u32 id,
void file_desc_add(struct file_desc *d, u32 id,
struct file_desc_ops *ops)
{
d->type = type;
d->id = id;
d->ops = ops;
INIT_LIST_HEAD(&d->fd_info_head);
......@@ -64,7 +63,7 @@ struct file_desc *find_file_desc_raw(int type, u32 id)
chain = &file_descs[id % FDESC_HASH_SIZE];
list_for_each_entry(d, chain, hash)
if (d->type == type && d->id == id)
if (d->ops->type == type && d->id == id)
return d;
return NULL;
......@@ -99,7 +98,7 @@ void show_saved_files(void)
list_for_each_entry(fd, &file_descs[i], hash) {
struct fdinfo_list_entry *le;
pr_info(" `- type %d ID %#x\n", fd->type, fd->id);
pr_info(" `- type %d ID %#x\n", fd->ops->type, fd->id);
list_for_each_entry(le, &fd->fd_info_head, desc_list)
pr_info(" `- FD %d pid %d\n", le->fe.fd, le->pid);
}
......@@ -161,6 +160,7 @@ int rst_file_params(int fd, fown_t *fown, int flags)
static int open_fe_fd(struct file_desc *d);
static struct file_desc_ops reg_desc_ops = {
.type = FDINFO_REG,
.open = open_fe_fd,
};
......@@ -322,8 +322,7 @@ int collect_reg_files(void)
rfi->path[len] = '\0';
pr_info("Collected [%s] ID %#x\n", rfi->path, rfi->rfe.id);
file_desc_add(&rfi->d, FDINFO_REG, rfi->rfe.id,
&reg_desc_ops);
file_desc_add(&rfi->d, rfi->rfe.id, &reg_desc_ops);
}
if (rfi) {
......
......@@ -37,12 +37,12 @@ struct fdinfo_list_entry {
struct file_desc;
struct file_desc_ops {
int type;
int (*open)(struct file_desc *);
int (*want_transport)(struct fdinfo_entry *, struct file_desc *);
};
struct file_desc {
int type;
u32 id;
struct list_head hash;
struct list_head fd_info_head;
......@@ -60,8 +60,7 @@ struct cr_fdset;
extern int do_dump_gen_file(struct fd_parms *p, int lfd,
const struct fdtype_ops *ops, const struct cr_fdset *cr_fdset);
extern void file_desc_add(struct file_desc *d, int type, u32 id,
struct file_desc_ops *ops);
extern void file_desc_add(struct file_desc *d, u32 id, struct file_desc_ops *ops);
extern struct fdinfo_list_entry *file_master(struct file_desc *d);
extern struct file_desc *find_file_desc_raw(int type, u32 id);
extern int send_fd_to_peer(int fd, struct fdinfo_list_entry *, int transport);
......
......@@ -303,6 +303,7 @@ static int open_inotify_fd(struct file_desc *d)
}
static struct file_desc_ops desc_ops = {
.type = FDINFO_INOTIFY,
.open = open_inotify_fd,
};
......@@ -375,7 +376,7 @@ int collect_inotify(void)
list_for_each_entry(info, &info_head, list) {
pr_info("Collected inotify: id 0x%08x flags 0x%08x\n", info->ife.id, info->ife.flags);
file_desc_add(&info->d, FDINFO_INOTIFY, info->ife.id, &desc_ops);
file_desc_add(&info->d, info->ife.id, &desc_ops);
}
ret = 0;
err:
......
......@@ -33,6 +33,7 @@ static int pipe_should_open_transport(struct fdinfo_entry *fe,
struct file_desc *d);
static struct file_desc_ops pipe_desc_ops = {
.type = FDINFO_PIPE,
.open = open_pipe,
.want_transport = pipe_should_open_transport,
};
......@@ -61,8 +62,7 @@ int collect_pipes(void)
pr_info("Collected pipe entry ID %#x PIPE ID %#x\n",
pi->pe.id, pi->pe.pipe_id);
file_desc_add(&pi->d, FDINFO_PIPE, pi->pe.id,
&pipe_desc_ops);
file_desc_add(&pi->d, pi->pe.id, &pipe_desc_ops);
list_for_each_entry(tmp, &pipes, list)
if (pi->pe.pipe_id == tmp->pe.pipe_id)
......
......@@ -177,6 +177,7 @@ int inet_collect_one(struct nlmsghdr *h, int family, int type, int proto)
static int open_inet_sk(struct file_desc *d);
static struct file_desc_ops inet_desc_ops = {
.type = FDINFO_INETSK,
.open = open_inet_sk,
};
......@@ -199,8 +200,7 @@ int collect_inet_sockets(void)
if (ret <= 0)
break;
file_desc_add(&ii->d, FDINFO_INETSK, ii->ie.id,
&inet_desc_ops);
file_desc_add(&ii->d, ii->ie.id, &inet_desc_ops);
if (tcp_connection(&ii->ie))
tcp_locked_conn_add(ii);
......
......@@ -679,6 +679,7 @@ static int open_unix_sk(struct file_desc *d)
}
static struct file_desc_ops unix_desc_ops = {
.type = FDINFO_UNIXSK,
.open = open_unix_sk,
.want_transport = unixsk_should_open_transport,
};
......@@ -740,8 +741,7 @@ int collect_unix_sockets(void)
ui->peer = NULL;
ui->flags = 0;
pr_info(" `- Got 0x%x peer 0x%x\n", ui->ue.id, ui->ue.peer);
file_desc_add(&ui->d, FDINFO_UNIXSK, ui->ue.id,
&unix_desc_ops);
file_desc_add(&ui->d, ui->ue.id, &unix_desc_ops);
list_add_tail(&ui->list, &unix_sockets);
}
......
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