From owner-svn-src-all@FreeBSD.ORG Fri Dec 13 21:49:42 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 32640CD1; Fri, 13 Dec 2013 21:49:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 04E4010FF; Fri, 13 Dec 2013 21:49:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rBDLnfEo036923; Fri, 13 Dec 2013 21:49:41 GMT (envelope-from asomers@svn.freebsd.org) Received: (from asomers@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rBDLnfYB036922; Fri, 13 Dec 2013 21:49:41 GMT (envelope-from asomers@svn.freebsd.org) Message-Id: <201312132149.rBDLnfYB036922@svn.freebsd.org> From: Alan Somers Date: Fri, 13 Dec 2013 21:49:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259339 - head/sbin/devd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Dec 2013 21:49:42 -0000 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