Commit 0a859275 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Andrei Vagin

fdstore: Unlimit fdstore queue on start

We use fdstore intensively for example when handling
bindmounted sockets and ghost dgram sockets. The system
limit for per-socket queue may not be enough if someone
generate lots of ghost sockets (150 and more as been
detected on default fedora 27).

To make it operatable lets unlimit fdstore queue size
on startup.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 077409c1
...@@ -20,6 +20,8 @@ static struct fdstore_desc { ...@@ -20,6 +20,8 @@ static struct fdstore_desc {
int fdstore_init(void) int fdstore_init(void)
{ {
/* In kernel a bufsize has type int and a value is doubled. */
uint32_t buf[2] = { INT_MAX / 2, INT_MAX / 2 };
struct sockaddr_un addr; struct sockaddr_un addr;
unsigned int addrlen; unsigned int addrlen;
struct stat st; struct stat st;
...@@ -44,6 +46,13 @@ int fdstore_init(void) ...@@ -44,6 +46,13 @@ int fdstore_init(void)
return -1; return -1;
} }
if (setsockopt(sk, SOL_SOCKET, SO_SNDBUFFORCE, &buf[0], sizeof(buf[0])) < 0 ||
setsockopt(sk, SOL_SOCKET, SO_RCVBUFFORCE, &buf[1], sizeof(buf[1])) < 0) {
pr_perror("Unable to set SO_SNDBUFFORCE/SO_RCVBUFFORCE");
close(sk);
return -1;
}
addr.sun_family = AF_UNIX; addr.sun_family = AF_UNIX;
addrlen = snprintf(addr.sun_path, sizeof(addr.sun_path), "X/criu-fdstore-%"PRIx64, st.st_ino); addrlen = snprintf(addr.sun_path, sizeof(addr.sun_path), "X/criu-fdstore-%"PRIx64, st.st_ino);
addrlen += sizeof(addr.sun_family); addrlen += sizeof(addr.sun_family);
...@@ -79,11 +88,13 @@ int fdstore_init(void) ...@@ -79,11 +88,13 @@ int fdstore_init(void)
int fdstore_add(int fd) int fdstore_add(int fd)
{ {
int sk = get_service_fd(FDSTORE_SK_OFF); int sk = get_service_fd(FDSTORE_SK_OFF);
int id; int id, ret;
mutex_lock(&desc->lock); mutex_lock(&desc->lock);
if (send_fd(sk, NULL, 0, fd)) { ret = send_fd(sk, NULL, 0, fd);
if (ret) {
pr_perror("Can't send fd %d into store\n", fd);
mutex_unlock(&desc->lock); mutex_unlock(&desc->lock);
return -1; return -1;
} }
......
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