[CRIU] [PATCH 10/14] files: pass a file descriptor on an fdinfo image instead of cr_fdset
Andrey Vagin
avagin at openvz.org
Fri Jan 11 04:22:41 EST 2013
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: Andrey Vagin <avagin at openvz.org>
---
cr-dump.c | 36 ++++++++++++++++++------------------
eventfd.c | 4 ++--
eventpoll.c | 4 ++--
fifo.c | 4 ++--
files-reg.c | 4 ++--
include/eventfd.h | 2 +-
include/eventpoll.h | 2 +-
include/fifo.h | 2 +-
include/files-reg.h | 2 +-
include/files.h | 2 +-
include/inotify.h | 2 +-
include/pipes.h | 2 +-
include/signalfd.h | 2 +-
include/sk-packet.h | 2 +-
include/sockets.h | 8 ++++----
include/tty.h | 2 +-
inotify.c | 4 ++--
pipes.c | 4 ++--
signalfd.c | 4 ++--
sk-inet.c | 8 ++++----
sk-packet.c | 4 ++--
sk-unix.c | 4 ++--
sockets.c | 10 +++++-----
tty.c | 4 ++--
24 files changed, 61 insertions(+), 61 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index 5504437..25ff91e 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -197,7 +197,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;
@@ -217,7 +217,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)
@@ -286,17 +286,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);
@@ -307,7 +307,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;
@@ -318,10 +318,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);
@@ -330,31 +330,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;
@@ -378,7 +378,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;
@@ -1422,7 +1422,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;
diff --git a/eventfd.c b/eventfd.c
index 1e48af2..1a8fca3 100644
--- a/eventfd.c
+++ b/eventfd.c
@@ -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)
diff --git a/eventpoll.c b/eventpoll.c
index ccce771..3c77bc6 100644
--- a/eventpoll.c
+++ b/eventpoll.c
@@ -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)
diff --git a/fifo.c b/fifo.c
index edc8a23..ea32bcf 100644
--- a/fifo.c
+++ b/fifo.c
@@ -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];
diff --git a/files-reg.c b/files-reg.c
index cf4fd71..66dfadd 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -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, ®file_ops, cr_fdset);
+ return do_dump_gen_file(p, lfd, ®file_ops, fdinfo);
}
static int open_path(struct file_desc *d,
diff --git a/include/eventfd.h b/include/eventfd.h
index 7515410..aed8ba4 100644
--- a/include/eventfd.h
+++ b/include/eventfd.h
@@ -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);
diff --git a/include/eventpoll.h b/include/eventpoll.h
index a2f5f11..03a4cc1 100644
--- a/include/eventpoll.h
+++ b/include/eventpoll.h
@@ -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);
diff --git a/include/fifo.h b/include/fifo.h
index bfa9612..dc5aecf 100644
--- a/include/fifo.h
+++ b/include/fifo.h
@@ -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__ */
diff --git a/include/files-reg.h b/include/files-reg.h
index 51022e7..b9aeff4 100644
--- a/include/files-reg.h
+++ b/include/files-reg.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);
diff --git a/include/files.h b/include/files.h
index b33ae17..9d829f2 100644
--- a/include/files.h
+++ b/include/files.h
@@ -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);
diff --git a/include/inotify.h b/include/inotify.h
index d45b2bc..8daf66a 100644
--- a/include/inotify.h
+++ b/include/inotify.h
@@ -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);
diff --git a/include/pipes.h b/include/pipes.h
index d31d48e..38855e4 100644
--- a/include/pipes.h
+++ b/include/pipes.h
@@ -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)
{
diff --git a/include/signalfd.h b/include/signalfd.h
index 2ac8ff5..c5d6978 100644
--- a/include/signalfd.h
+++ b/include/signalfd.h
@@ -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);
diff --git a/include/sk-packet.h b/include/sk-packet.h
index a998c33..675c932 100644
--- a/include/sk-packet.h
+++ b/include/sk-packet.h
@@ -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 *);
diff --git a/include/sockets.h b/include/sockets.h
index ed3ac09..22ffd9b 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -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 *);
diff --git a/include/tty.h b/include/tty.h
index bf370ab..e7e653a 100644
--- a/include/tty.h
+++ b/include/tty.h
@@ -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);
diff --git a/inotify.c b/inotify.c
index c7f7365..3d574ba 100644
--- a/inotify.c
+++ b/inotify.c
@@ -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)
diff --git a/pipes.c b/pipes.c
index 6542ec6..e595a3a 100644
--- a/pipes.c
+++ b/pipes.c
@@ -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);
}
diff --git a/signalfd.c b/signalfd.c
index 3eccb96..eeaef9f 100644
--- a/signalfd.c
+++ b/signalfd.c
@@ -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)
diff --git a/sk-inet.c b/sk-inet.c
index 25581ba..b411c28 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -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)
diff --git a/sk-packet.c b/sk-packet.c
index 3391b5d..9b667c4 100644
--- a/sk-packet.c
+++ b/sk-packet.c
@@ -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)
diff --git a/sk-unix.c b/sk-unix.c
index c6ec844..ce37dbc 100644
--- a/sk-unix.c
+++ b/sk-unix.c
@@ -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,
diff --git a/sockets.c b/sockets.c
index 3d617d8..175d165 100644
--- a/sockets.c
+++ b/sockets.c
@@ -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;
diff --git a/tty.c b/tty.c
index de74d41..5a78a0f 100644
--- a/tty.c
+++ b/tty.c
@@ -1188,9 +1188,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)
--
1.7.11.7
More information about the CRIU
mailing list