svn commit: r259339 - head/sbin/devd

Alan Somers asomers at FreeBSD.org
Fri Dec 13 21:49:42 UTC 2013


Author: asomers
Date: Fri Dec 13 21:49:41 2013
New Revision: 259339
URL: http://svnweb.freebsd.org/changeset/base/259339

Log:
  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

Modified:
  head/sbin/devd/devd.cc

Modified: head/sbin/devd/devd.cc
==============================================================================
--- head/sbin/devd/devd.cc	Fri Dec 13 21:46:53 2013	(r259338)
+++ head/sbin/devd/devd.cc	Fri Dec 13 21:49:41 2013	(r259339)
@@ -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


More information about the svn-src-all mailing list