From owner-svn-src-all@FreeBSD.ORG Mon Jul 1 07:25:42 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DD7A9C98; Mon, 1 Jul 2013 07:25:42 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from anubis.delphij.net (anubis.delphij.net [IPv6:2001:470:1:117::25]) by mx1.freebsd.org (Postfix) with ESMTP id C185F128B; Mon, 1 Jul 2013 07:25:42 +0000 (UTC) Received: from delphij-macbook.local (c-67-188-85-47.hsd1.ca.comcast.net [67.188.85.47]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by anubis.delphij.net (Postfix) with ESMTPSA id EE90D1E119; Mon, 1 Jul 2013 00:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=delphij.net; s=anubis; t=1372663542; bh=INtdzwANJyLXvVB+y1MO6EvTI7vBp4XiuFUZwds4Pxg=; h=Date:From:Reply-To:To:CC:Subject:References:In-Reply-To; b=lPcmMnehjnFpcv+86JcNvjqTM5Vq9KPK8vdyiUgRb4Uv5Euy0Qc5b9YjpLDt72TG3 5zWF0NNLvZustzwZjqtMrCIdXjBwZZfWSFNFUqe1PL28x8vVdCnH0UqbK5o8Yu76To tXnGubzsBKDicst46cHOK1TYLhVGghYFDSTyshvc= Message-ID: <51D12EF8.5000108@delphij.net> Date: Mon, 01 Jul 2013 00:25:44 -0700 From: Xin Li Organization: The FreeBSD Project MIME-Version: 1.0 To: "Pedro F. Giffuni" Subject: Re: svn commit: r252435 - in head/sys/ufs: ffs ufs References: <201307010300.r6130GWT035496@svn.freebsd.org> In-Reply-To: <201307010300.r6130GWT035496@svn.freebsd.org> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: d@delphij.net 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: Mon, 01 Jul 2013 07:25:42 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 6/30/13 8:00 PM, Pedro F. Giffuni wrote: > Author: pfg Date: Mon Jul 1 03:00:15 2013 New Revision: 252435 > URL: http://svnweb.freebsd.org/changeset/base/252435 > > Log: Change i_gen in UFS to an unsigned type. > [...] > Modified: head/sys/ufs/ffs/ffs_vfsops.c > ============================================================================== > > - --- head/sys/ufs/ffs/ffs_vfsops.c Mon Jul 1 02:48:27 2013 (r252434) > +++ head/sys/ufs/ffs/ffs_vfsops.c Mon Jul 1 03:00:15 2013 > (r252435) @@ -1791,7 +1791,7 @@ ffs_vgetf(mp, ino, flags, vpp, > ffs_flags * already have one. This should only happen on old > filesystems. */ if (ip->i_gen == 0) { - ip->i_gen = arc4random() / > 2 + 1; + ip->i_gen = arc4random() + 1; if ((vp->v_mount->mnt_flag > & MNT_RDONLY) == 0) { ip->i_flag |= IN_MODIFIED; DIP_SET(ip, i_gen, > ip->i_gen); > Why ip->i_gen must be non-zero here? (I think it does not. Note that arc4random() can return UINT32_MAX so the new code does not guarantee this anyway, while old code does). If my understanding of the code is right, I think it doesn't really hurt to have 0 in ip->i_gen in the places where arc4random() is used (next time it would be regenerated), so probably we can just use ip->i_gen = arc4random()? However, if I was wrong, you probably want some construction like this: %%% for (;;) { %%% ip->i_gen = arc4random(); %%% if (ip->i_gen != UINT32_MAX) %%% break; %%% } %%% ip->i_gen++; Or we probably need to import a variant of arc4random_uniform into kernel? Cheers, -----BEGIN PGP SIGNATURE----- iQEcBAEBCAAGBQJR0S74AAoJEG80Jeu8UPuzoRgIAJ5xyeUkJf6KGVdz3KkhuJ+m YJ6MjNZDo8xEcbZcuuH4PzzFyZZrO7puL0wMjlEN8fJIWkf/mXLpN+pAdVgU6h8Y A3plrlznEZH/s/G+FdZnHC1aIrizk/F2pm+/ev+e4kUX0covbreiK3gOAEsmi4Ik sfcsh+JCFrbbICQbN09EtUdfgmFdIPT+uni95gYdZ9K5poOeJ5NgsN9aDv2V0qJR pyLmWE26cj+SgfJhCahmoHXjVSgywG4O4XnAqxTUMbVRsV7ELYwJjugCKib1UFPl axwFc3Oh8KlFlczAgkWbSlf8ea5Jql1o6PXYQvuGHBUQdY5gQLXAAJMdc4iFIrY= =3RzL -----END PGP SIGNATURE-----