Commit 0fc129a1 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

files: pass a file descriptor on an fdinfo image instead of cr_fdset

Currently fdinfo dumps for each task, so CR_FD_FDINFO is in cr_fdset.
A few tasks can share one fd table and the set of descriptors will be
dumped once and a image name will contain files_id instead of pid.
In this case CR_FD_FDINFO will go away from cr_fdset.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent dcf158e2
......@@ -198,7 +198,7 @@ static u32 make_gen_id(const struct fd_parms *p)
}
int do_dump_gen_file(struct fd_parms *p, int lfd,
const struct fdtype_ops *ops, const struct cr_fdset *cr_fdset)
const struct fdtype_ops *ops, const int fdinfo)
{
FdinfoEntry e = FDINFO_ENTRY__INIT;
int ret = -1;
......@@ -218,7 +218,7 @@ int do_dump_gen_file(struct fd_parms *p, int lfd,
pr_info("fdinfo: type: 0x%2x flags: %#o/%#o pos: 0x%8lx fd: %d\n",
ops->type, p->flags, (int)p->fd_flags, p->pos, p->fd);
return pb_write_one(fdset_fd(cr_fdset, CR_FD_FDINFO), &e, PB_FDINFO);
return pb_write_one(fdinfo, &e, PB_FDINFO);
}
static int dump_task_exe_link(pid_t pid, MmEntry *mm)
......@@ -287,17 +287,17 @@ static int dump_unsupp_fd(const struct fd_parms *p)
return -1;
}
static int dump_chrdev(struct fd_parms *p, int lfd, const struct cr_fdset *set)
static int dump_chrdev(struct fd_parms *p, int lfd, const int fdinfo)
{
int maj = major(p->stat.st_rdev);
switch (maj) {
case MEM_MAJOR:
return dump_reg_file(p, lfd, set);
return dump_reg_file(p, lfd, fdinfo);
case TTYAUX_MAJOR:
case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
case UNIX98_PTY_SLAVE_MAJOR:
return dump_tty(p, lfd, set);
return dump_tty(p, lfd, fdinfo);
}
return dump_unsupp_fd(p);
......@@ -308,7 +308,7 @@ static int dump_chrdev(struct fd_parms *p, int lfd, const struct cr_fdset *set)
#endif
static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_opts *opts,
const struct cr_fdset *cr_fdset)
const int fdinfo)
{
struct fd_parms p;
struct statfs statfs;
......@@ -319,10 +319,10 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op
}
if (S_ISSOCK(p.stat.st_mode))
return dump_socket(&p, lfd, cr_fdset);
return dump_socket(&p, lfd, fdinfo);
if (S_ISCHR(p.stat.st_mode))
return dump_chrdev(&p, lfd, cr_fdset);
return dump_chrdev(&p, lfd, fdinfo);
if (fstatfs(lfd, &statfs)) {
pr_perror("Can't obtain statfs on fd %d\n", fd);
......@@ -331,31 +331,31 @@ static int dump_one_file(struct parasite_ctl *ctl, int fd, int lfd, struct fd_op
if (is_anon_inode(&statfs)) {
if (is_eventfd_link(lfd))
return dump_eventfd(&p, lfd, cr_fdset);
return dump_eventfd(&p, lfd, fdinfo);
else if (is_eventpoll_link(lfd))
return dump_eventpoll(&p, lfd, cr_fdset);
return dump_eventpoll(&p, lfd, fdinfo);
else if (is_inotify_link(lfd))
return dump_inotify(&p, lfd, cr_fdset);
return dump_inotify(&p, lfd, fdinfo);
else if (is_signalfd_link(lfd))
return dump_signalfd(&p, lfd, cr_fdset);
return dump_signalfd(&p, lfd, fdinfo);
else
return dump_unsupp_fd(&p);
}
if (S_ISREG(p.stat.st_mode) || S_ISDIR(p.stat.st_mode))
return dump_reg_file(&p, lfd, cr_fdset);
return dump_reg_file(&p, lfd, fdinfo);
if (S_ISFIFO(p.stat.st_mode)) {
if (statfs.f_type == PIPEFS_MAGIC)
return dump_pipe(&p, lfd, cr_fdset);
return dump_pipe(&p, lfd, fdinfo);
else
return dump_fifo(&p, lfd, cr_fdset);
return dump_fifo(&p, lfd, fdinfo);
}
return dump_unsupp_fd(&p);
}
static int dump_task_files_seized(struct parasite_ctl *ctl, const struct cr_fdset *cr_fdset,
static int dump_task_files_seized(struct parasite_ctl *ctl, const int fdinfo,
struct parasite_drain_fd *dfds)
{
int *lfds;
......@@ -379,7 +379,7 @@ static int dump_task_files_seized(struct parasite_ctl *ctl, const struct cr_fdse
goto err2;
for (i = 0; i < dfds->nr_fds; i++) {
ret = dump_one_file(ctl, dfds->fds[i], lfds[i], opts + i, cr_fdset);
ret = dump_one_file(ctl, dfds->fds[i], lfds[i], opts + i, fdinfo);
close(lfds[i]);
if (ret)
goto err2;
......@@ -1439,7 +1439,7 @@ static int dump_one_task(struct pstree_item *item)
if (!cr_fdset)
goto err_cure;
ret = dump_task_files_seized(parasite_ctl, cr_fdset, dfds);
ret = dump_task_files_seized(parasite_ctl, fdset_fd(cr_fdset, CR_FD_FDINFO), dfds);
if (ret) {
pr_err("Dump files (pid: %d) failed with %d\n", pid, ret);
goto err_cure;
......
......@@ -85,9 +85,9 @@ static const struct fdtype_ops eventfd_ops = {
.dump = dump_one_eventfd,
};
int dump_eventfd(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_eventfd(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &eventfd_ops, set);
return do_dump_gen_file(p, lfd, &eventfd_ops, fdinfo);
}
static int eventfd_open(struct file_desc *d)
......
......@@ -97,9 +97,9 @@ static const struct fdtype_ops eventpoll_ops = {
.dump = dump_one_eventpoll,
};
int dump_eventpoll(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_eventpoll(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &eventpoll_ops, set);
return do_dump_gen_file(p, lfd, &eventpoll_ops, fdinfo);
}
static int eventpoll_open(struct file_desc *d)
......
......@@ -68,9 +68,9 @@ static const struct fdtype_ops fifo_ops = {
.dump = dump_one_fifo,
};
int dump_fifo(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_fifo(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &fifo_ops, set);
return do_dump_gen_file(p, lfd, &fifo_ops, fdinfo);
}
static struct pipe_data_rst *pd_hash_fifo[PIPE_DATA_HASH_SIZE];
......
......@@ -469,9 +469,9 @@ static const struct fdtype_ops regfile_ops = {
};
int dump_reg_file(struct fd_parms *p, int lfd,
const struct cr_fdset *cr_fdset)
const int fdinfo)
{
return do_dump_gen_file(p, lfd, &regfile_ops, cr_fdset);
return do_dump_gen_file(p, lfd, &regfile_ops, fdinfo);
}
static int open_path(struct file_desc *d,
......
......@@ -10,7 +10,7 @@
#include "crtools.h"
extern int is_eventfd_link(int lfd);
extern int dump_eventfd(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_eventfd(struct fd_parms *p, int lfd, const int fdinfo);
extern int collect_eventfd(void);
extern void show_eventfds(int fd, struct cr_options *o);
......
......@@ -10,7 +10,7 @@
#include "crtools.h"
extern int is_eventpoll_link(int lfd);
extern int dump_eventpoll(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_eventpoll(struct fd_parms *p, int lfd, const int fdinfo);
extern int collect_eventpoll(void);
extern void show_eventpoll(int fd, struct cr_options *o);
extern void show_eventpoll_tfd(int fd, struct cr_options *o);
......
......@@ -4,7 +4,7 @@
struct fd_parms;
struct cr_fdset;
extern int dump_fifo(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_fifo(struct fd_parms *p, int lfd, const int fdinfo);
extern int collect_fifo(void);
#endif /* __CR_FIFO_H__ */
......@@ -30,7 +30,7 @@ extern int collect_reg_files(void);
extern int prepare_shared_reg_files(void);
extern int dump_reg_file(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset);
extern int dump_reg_file(struct fd_parms *p, int lfd, const int fdinfo);
extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p);
extern struct file_remap *lookup_ghost_remap(u32 dev, u32 ino);
......
......@@ -74,7 +74,7 @@ struct fdtype_ops {
extern int do_dump_gen_file(struct fd_parms *p, int lfd,
const struct fdtype_ops *ops,
const struct cr_fdset *cr_fdset);
const int fdinfo);
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);
......
......@@ -10,7 +10,7 @@
#include "crtools.h"
extern int is_inotify_link(int lfd);
extern int dump_inotify(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_inotify(struct fd_parms *p, int lfd, const int fdinfo);
extern int collect_inotify(void);
extern void show_inotify_wd(int fd_inotify_wd, struct cr_options *o);
extern void show_inotify(int fd_inotify, struct cr_options *o);
......
......@@ -6,7 +6,7 @@
extern int collect_pipes(void);
extern void mark_pipe_master(void);
int dump_pipe(struct fd_parms *p, int lfd,
const struct cr_fdset *cr_fdset);
const int fdinfo);
static inline u32 pipe_id(const struct fd_parms *p)
{
......
......@@ -5,7 +5,7 @@ struct cr_fdset;
struct fd_parms;
struct cr_options;
extern int is_signalfd_link(int lfd);
extern int dump_signalfd(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_signalfd(struct fd_parms *p, int lfd, const int fdinfo);
extern void show_signalfd(int fd, struct cr_options *o);
extern int collect_signalfd(void);
......
......@@ -10,7 +10,7 @@ struct fd_parms;
struct cr_options;
struct vma_area;
int dump_one_packet_sk(struct fd_parms *p, int lfd, const struct cr_fdset *fds);
int dump_one_packet_sk(struct fd_parms *p, int lfd, const int fdinfo);
int collect_packet_sockets(void);
void show_packetsk(int fd, struct cr_options *);
......
......@@ -26,7 +26,7 @@ struct socket_desc {
int already_dumped;
};
extern int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset);
extern int dump_socket(struct fd_parms *p, int lfd, const int fdinfo);
extern int dump_socket_opts(int sk, SkOptsEntry *soe);
extern int restore_socket_opts(int sk, SkOptsEntry *soe);
extern void release_skopts(SkOptsEntry *);
......@@ -50,9 +50,9 @@ extern char *skstate2s(u32 state);
extern struct socket_desc *lookup_socket(int ino, int family);
extern int dump_one_inet(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_one_inet6(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_one_unix(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_one_inet(struct fd_parms *p, int lfd, const int fdinfo);
extern int dump_one_inet6(struct fd_parms *p, int lfd, const int fdinfo);
extern int dump_one_unix(struct fd_parms *p, int lfd, const int fdinfo);
extern int inet_collect_one(struct nlmsghdr *h, int family, int type, int proto);
extern int unix_receive_one(struct nlmsghdr *h, void *);
......
......@@ -13,7 +13,7 @@
#endif
#define PTS_FMT "/dev/pts/%d"
extern int dump_tty(struct fd_parms *p, int lfd, const struct cr_fdset *set);
extern int dump_tty(struct fd_parms *p, int lfd, const int fdinfo);
extern int dump_verify_tty_sids(void);
extern int collect_tty(void);
extern int prepare_shared_tty(void);
......
......@@ -105,9 +105,9 @@ static const struct fdtype_ops inotify_ops = {
.dump = dump_one_inotify,
};
int dump_inotify(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_inotify(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &inotify_ops, set);
return do_dump_gen_file(p, lfd, &inotify_ops, fdinfo);
}
static int restore_one_inotify(int inotify_fd, struct inotify_wd_info *info)
......
......@@ -440,7 +440,7 @@ static const struct fdtype_ops pipe_ops = {
.dump = dump_one_pipe,
};
int dump_pipe(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
int dump_pipe(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &pipe_ops, cr_fdset);
return do_dump_gen_file(p, lfd, &pipe_ops, fdinfo);
}
......@@ -65,9 +65,9 @@ static const struct fdtype_ops signalfd_ops = {
.dump = dump_one_signalfd,
};
int dump_signalfd(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_signalfd(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &signalfd_ops, set);
return do_dump_gen_file(p, lfd, &signalfd_ops, fdinfo);
}
static void sigset_fill(sigset_t *to, unsigned long long from)
......
......@@ -315,9 +315,9 @@ static const struct fdtype_ops inet_dump_ops = {
.dump = dump_one_inet_fd,
};
int dump_one_inet(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_one_inet(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &inet_dump_ops, set);
return do_dump_gen_file(p, lfd, &inet_dump_ops, fdinfo);
}
static int dump_one_inet6_fd(int lfd, u32 id, const struct fd_parms *p)
......@@ -330,9 +330,9 @@ static const struct fdtype_ops inet6_dump_ops = {
.dump = dump_one_inet6_fd,
};
int dump_one_inet6(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_one_inet6(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &inet6_dump_ops, set);
return do_dump_gen_file(p, lfd, &inet6_dump_ops, fdinfo);
}
int inet_collect_one(struct nlmsghdr *h, int family, int type, int proto)
......
......@@ -208,9 +208,9 @@ static const struct fdtype_ops packet_dump_ops = {
.dump = dump_one_packet_fd,
};
int dump_one_packet_sk(struct fd_parms *p, int lfd, const struct cr_fdset *fds)
int dump_one_packet_sk(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &packet_dump_ops, fds);
return do_dump_gen_file(p, lfd, &packet_dump_ops, fdinfo);
}
int dump_socket_map(struct vma_area *vma)
......
......@@ -242,9 +242,9 @@ static const struct fdtype_ops unix_dump_ops = {
.dump = dump_one_unix_fd,
};
int dump_one_unix(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_one_unix(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &unix_dump_ops, set);
return do_dump_gen_file(p, lfd, &unix_dump_ops, fdinfo);
}
static int unix_collect_one(const struct unix_diag_msg *m,
......
......@@ -366,7 +366,7 @@ void release_skopts(SkOptsEntry *soe)
xfree(soe->so_bound_dev);
}
int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
int dump_socket(struct fd_parms *p, int lfd, const int fdinfo)
{
int family;
......@@ -375,13 +375,13 @@ int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
switch (family) {
case AF_UNIX:
return dump_one_unix(p, lfd, cr_fdset);
return dump_one_unix(p, lfd, fdinfo);
case AF_INET:
return dump_one_inet(p, lfd, cr_fdset);
return dump_one_inet(p, lfd, fdinfo);
case AF_INET6:
return dump_one_inet6(p, lfd, cr_fdset);
return dump_one_inet6(p, lfd, fdinfo);
case AF_PACKET:
return dump_one_packet_sk(p, lfd, cr_fdset);
return dump_one_packet_sk(p, lfd, fdinfo);
default:
pr_err("BUG! Unknown socket collected\n");
break;
......
......@@ -1189,9 +1189,9 @@ static const struct fdtype_ops tty_ops = {
.dump = dump_one_pty,
};
int dump_tty(struct fd_parms *p, int lfd, const struct cr_fdset *set)
int dump_tty(struct fd_parms *p, int lfd, const int fdinfo)
{
return do_dump_gen_file(p, lfd, &tty_ops, set);
return do_dump_gen_file(p, lfd, &tty_ops, fdinfo);
}
int tty_prep_fds(void)
......
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