Date: Mon, 01 Jul 2013 00:25:44 -0700 From: Xin Li <delphij@delphij.net> To: "Pedro F. Giffuni" <pfg@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r252435 - in head/sys/ufs: ffs ufs Message-ID: <51D12EF8.5000108@delphij.net> In-Reply-To: <201307010300.r6130GWT035496@svn.freebsd.org> References: <201307010300.r6130GWT035496@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
-----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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51D12EF8.5000108>