Date: Tue, 7 Jun 2016 14:37:44 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301548 - head/sys/fs/ext2fs Message-ID: <201606071437.u57EbiO6003579@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Tue Jun 7 14:37:43 2016 New Revision: 301548 URL: https://svnweb.freebsd.org/changeset/base/301548 Log: ext2fs: cleanup generation number management. Ext2/3/4 manages generation numbers differently than UFS so adopt some rules that should work well. When allocating a new inode, make sure we generate a "good" random value specifically avoiding zero. Don't interfere with the numbers that are already generated in the filesystem: ext2fs doesn't have the backwards compatibility issues where there were no generation numbers. Reviewed by: kevlo MFC after: 1 week Modified: head/sys/fs/ext2fs/ext2_alloc.c head/sys/fs/ext2fs/ext2_vfsops.c Modified: head/sys/fs/ext2fs/ext2_alloc.c ============================================================================== --- head/sys/fs/ext2fs/ext2_alloc.c Tue Jun 7 14:16:10 2016 (r301547) +++ head/sys/fs/ext2fs/ext2_alloc.c Tue Jun 7 14:37:43 2016 (r301548) @@ -407,9 +407,11 @@ ext2_valloc(struct vnode *pvp, int mode, /* * Set up a new generation number for this inode. + * Avoid zero values. */ - while (ip->i_gen == 0 || ++ip->i_gen == 0) + do { ip->i_gen = arc4random(); + } while ( ip->i_gen == 0); vfs_timestamp(&ts); ip->i_birthtime = ts.tv_sec; Modified: head/sys/fs/ext2fs/ext2_vfsops.c ============================================================================== --- head/sys/fs/ext2fs/ext2_vfsops.c Tue Jun 7 14:16:10 2016 (r301547) +++ head/sys/fs/ext2fs/ext2_vfsops.c Tue Jun 7 14:37:43 2016 (r301548) @@ -993,16 +993,6 @@ ext2_vget(struct mount *mp, ino_t ino, i * Finish inode initialization. */ - /* - * Set up a generation number for this inode if it does not - * already have one. This should only happen on old filesystems. - */ - if (ip->i_gen == 0) { - while (ip->i_gen == 0) - ip->i_gen = arc4random(); - if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) - ip->i_flag |= IN_MODIFIED; - } *vpp = vp; return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606071437.u57EbiO6003579>