[CRIU] [PATCH 4/4] files: change PARASITE_MAX_FDS to work with the default file limit
Andrey Vagin
avagin at openvz.org
Tue Apr 5 12:29:40 PDT 2016
From: Andrew Vagin <avagin at virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
criu/include/parasite.h | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/criu/include/parasite.h b/criu/include/parasite.h
index 5c4aefe..93273a4 100644
--- a/criu/include/parasite.h
+++ b/criu/include/parasite.h
@@ -222,7 +222,15 @@ static inline void copy_sas(ThreadSasEntry *dst, const stack_t *src)
dst->ss_flags = src->ss_flags;
}
-#define PARASITE_MAX_FDS (PAGE_SIZE / sizeof(int))
+/*
+ * How many descriptrs can be transfered from parasite:
+ *
+ * 1) struct parasite_drain_fd + all descriptors should fit into one page
+ * 2) The value should be a multiple of CR_SCM_MAX_FD, because descriptors
+ * are transfered with help of send_fds and recv_fds.
+ * 3) criu should work with a defaul value of the file limit (1024)
+ */
+#define PARASITE_MAX_FDS CR_SCM_MAX_FD * 3
struct parasite_drain_fd {
int nr_fds;
@@ -233,7 +241,10 @@ struct parasite_drain_fd {
static inline int drain_fds_size(struct parasite_drain_fd *dfds)
{
int nr_fds = min((int)PARASITE_MAX_FDS, dfds->nr_fds);
- return sizeof(*dfds) + nr_fds * sizeof(dfds->fds[0]);
+
+ BUILD_BUG_ON(sizeof(*dfds) + PARASITE_MAX_FDS * sizeof(dfds->fds[0]) > PAGE_SIZE);
+
+ return sizeof(dfds) + nr_fds * sizeof(dfds->fds[0]);
}
struct parasite_tty_args {
--
2.5.0
More information about the CRIU
mailing list