From owner-freebsd-current@FreeBSD.ORG Tue Oct 4 10:20:59 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CD94106566B; Tue, 4 Oct 2011 10:20:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id C8F798FC1F; Tue, 4 Oct 2011 10:20:58 +0000 (UTC) Received: from alf.home (alf.kiev.zoral.com.ua [10.1.1.177]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id p94AKmAt075857 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 4 Oct 2011 13:20:48 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from alf.home (kostik@localhost [127.0.0.1]) by alf.home (8.14.5/8.14.5) with ESMTP id p94AKmiE087031; Tue, 4 Oct 2011 13:20:48 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by alf.home (8.14.5/8.14.5/Submit) id p94AKmTu087030; Tue, 4 Oct 2011 13:20:48 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: alf.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 4 Oct 2011 13:20:48 +0300 From: Kostik Belousov To: Peter Jeremy Message-ID: <20111004102048.GG1511@deviant.kiev.zoral.com.ua> References: <20111002220405.GN1511@deviant.kiev.zoral.com.ua> <20111004063727.GA25129@server.vk2pj.dyndns.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="saLunEaUy7BLkUpu" Content-Disposition: inline In-Reply-To: <20111004063727.GA25129@server.vk2pj.dyndns.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: standards@freebsd.org, current@freebsd.org Subject: Re: st_dev and st_ino for pipes X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 10:20:59 -0000 --saLunEaUy7BLkUpu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 04, 2011 at 05:37:27PM +1100, Peter Jeremy wrote: > On 2011-Oct-03 01:04:05 +0300, Kostik Belousov wrot= e: > >Our implementation of pipes does not provide useful values for st_dev > >and st_ino when stat(2) is done on an anonymous pipe. It was noted by the > ... > >Patch below implements the requirement, by the cost of the small overhead > >at the pipe creation time, and slightly bigger cost at the destruction. >=20 > Does it need to be so complex? This information isn't needed by the > kernel and, to be "meaningful", all that is required is that the > (st_dev,st_ino) pair is unique within the system. Given this, > wouldn't it be sufficient to fake up a st_dev and then just make > st_ino be a counter that starts from 0 and increments (atomically?) on > every new pipe? No need to retain state or "free" anything when the > pipe is destroyed. (If necessary, pick a new fake st_dev when st_ino > wraps). Yes, you described the problem. The (st_dev, st_ino) pair must be globally unique in system, not only for the pipes, but for whole domain of file descriptors. This is the reason that I allocate a value for pipe st_dev using the same devfs mechanism as it is done for device numbers. Using simple incrementing counter for pipe inodes, together with allocating yet another st_dev gives essentially the same complications wrt KPI, and feels unclean. >=20 > >--- a/sys/kern/sys_pipe.c > >+++ b/sys/kern/sys_pipe.c > ... > >+static ino_t pipedev_ino; > .. > >+ ub->st_dev =3D pipedev_ino; >=20 > st_dev is a dev_t and hence pipedev_ino (which seems misnamed to me) > should probably be dev_t rather than ino_t Fixed. Thank you. --saLunEaUy7BLkUpu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk6K3f8ACgkQC3+MBN1Mb4hTXgCfQFZL163Ze6dJs/qUcGZwcs2O vlAAn2KDt4LVMmSCcF9DyGHn5tRekUEe =3C3S -----END PGP SIGNATURE----- --saLunEaUy7BLkUpu--