From owner-svn-src-head@FreeBSD.ORG Thu Sep 4 19:11:43 2014 Return-Path: Delivered-To: svn-src-head@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 B1D30BCF; Thu, 4 Sep 2014 19:11:43 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88EB4193A; Thu, 4 Sep 2014 19:11:43 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-70-85-31.nwrknj.fios.verizon.net [173.70.85.31]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 975C2B97F; Thu, 4 Sep 2014 15:11:42 -0400 (EDT) From: John Baldwin To: Benno Rice Subject: Re: svn commit: r271085 - head/lib/libgeom Date: Thu, 04 Sep 2014 13:49:51 -0400 Message-ID: <15042946.uzA1DvBfCL@ralph.baldwin.cx> User-Agent: KMail/4.10.5 (FreeBSD/10.0-STABLE; KDE/4.10.5; amd64; ; ) In-Reply-To: <10BDD3FC-EED9-4A47-BAF4-8F3C2925A3E3@FreeBSD.org> References: <201409040331.s843Vn5c048905@svn.freebsd.org> <3000146.5OWvozVApa@ralph.baldwin.cx> <10BDD3FC-EED9-4A47-BAF4-8F3C2925A3E3@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 04 Sep 2014 15:11:42 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Sep 2014 19:11:43 -0000 On Thursday, September 04, 2014 09:29:24 AM Benno Rice wrote: > On Sep 4, 2014, at 6:51 AM, John Baldwin wrote: > > On Thursday, September 04, 2014 03:31:49 AM Benno Rice wrote: > >> Author: benno > >> Date: Thu Sep 4 03:31:48 2014 > >> New Revision: 271085 > >> URL: http://svnweb.freebsd.org/changeset/base/271085 > >>=20 > >> Log: > >> Systems with lots of geom providers can end up with a kern.geom.c= onfxml > >> value too large for the buffer allocated. Work around this by ret= rying > >> a few times with larger buffer sizes. > >=20 > > Are these systems having lots of changes to the GEOM tree while the= sysctl > > handler is being invoked? If the tree is static, the first call wi= th an > > old of NULL should return the correct length in 'l' regardless of t= he > > size as it generates the entire buffer and SYSCTL_OUT's it. (It do= esn't > > do it piecemeal and fail on ENOMEM part way through the way some ot= her > > broken sysctl handlers do.) >=20 > These systems have a lot of drives in them and around the time when w= e=E2=80=99re > trying to enumerate there can be lots of activity. In the case where = the > tree hasn=E2=80=99t changed we=E2=80=99re not doing that much extra w= ork here and it saves > us having to retry everything that happens around the geom_getxml cal= ls > inside libgeom when the tree does change. I more meant that the commit message implied you needed this to handle = a large=20 buffer, but that shouldn't be true. You should only need this to handl= e large=20 changes in the size of the buffer. (I.e. it grows by more than 4k in b= etween=20 the first two sysctl() invocations.) Doubling the size on each iterati= on is=20 one approach (and is fine), another common one is to keep both sysctls = in the=20 loop so you fetch the new size in each iteration, e.g.: buf =3D NULL; for (;;) { sysctl(..., NULL, &len); buf =3D realloc(buf, len); sysctl(..., buf, &len); } --=20 John Baldwin