Commit a4205bba authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

files: change PARASITE_MAX_FDS to work with the default file limit

Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 96a355ab
...@@ -222,7 +222,15 @@ static inline void copy_sas(ThreadSasEntry *dst, const stack_t *src) ...@@ -222,7 +222,15 @@ static inline void copy_sas(ThreadSasEntry *dst, const stack_t *src)
dst->ss_flags = src->ss_flags; 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 { struct parasite_drain_fd {
int nr_fds; int nr_fds;
...@@ -232,7 +240,10 @@ struct parasite_drain_fd { ...@@ -232,7 +240,10 @@ struct parasite_drain_fd {
static inline int drain_fds_size(struct parasite_drain_fd *dfds) static inline int drain_fds_size(struct parasite_drain_fd *dfds)
{ {
int nr_fds = min((int)PARASITE_MAX_FDS, dfds->nr_fds); 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 { struct parasite_tty_args {
......
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