sbin/devd/devd.cc
Increase the size of devd's client socket's send buffer from the default (8k) to 128k. This prevents clients from getting POLLHUPped during event storms. For example, during zpool creation, the kernel emits a resource.fs.zfs.statechange event for every vdev in the pool. A 128k buffer is large enough to hold the statechange events for a pool with nearly 800 drives. Reviewed by: ian, imp Approved by: ken (mentor) Sponsored by: Spectra Logic Corp MFC after: 4 weeks
This commit is contained in:
parent
c2a48c0d1b
commit
b026eddfea
@ -104,6 +104,19 @@ __FBSDID("$FreeBSD$");
|
||||
#define CF "/etc/devd.conf"
|
||||
#define SYSCTL "hw.bus.devctl_disable"
|
||||
|
||||
/*
|
||||
* Since the client socket is nonblocking, we must increase its send buffer to
|
||||
* handle brief event storms. On FreeBSD, AF_UNIX sockets don't have a receive
|
||||
* buffer, so the client can't increate the buffersize by itself.
|
||||
*
|
||||
* For example, when creating a ZFS pool, devd emits one 165 character
|
||||
* resource.fs.zfs.statechange message for each vdev in the pool. A 64k
|
||||
* buffer has enough space for almost 400 drives, which would be very large but
|
||||
* not impossibly large pool. A 128k buffer has enough space for 794 drives,
|
||||
* which is more than can fit in a rack with modern technology.
|
||||
*/
|
||||
#define CLIENT_BUFSIZE 131072
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern FILE *yyin;
|
||||
@ -892,6 +905,7 @@ void
|
||||
new_client(int fd)
|
||||
{
|
||||
int s;
|
||||
int sndbuf_size;
|
||||
|
||||
/*
|
||||
* First go reap any zombie clients, then accept the connection, and
|
||||
@ -901,10 +915,15 @@ new_client(int fd)
|
||||
check_clients();
|
||||
s = accept(fd, NULL, NULL);
|
||||
if (s != -1) {
|
||||
sndbuf_size = CLIENT_BUFSIZE;
|
||||
if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &sndbuf_size,
|
||||
sizeof(sndbuf_size)))
|
||||
err(1, "setsockopt");
|
||||
shutdown(s, SHUT_RD);
|
||||
clients.push_back(s);
|
||||
++num_clients;
|
||||
}
|
||||
} else
|
||||
err(1, "accept");
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user