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
This commit is contained in:
Pedro F. Giffuni 2016-06-07 14:37:43 +00:00
parent 537f1d275f
commit 43ce40e891
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=301548
2 changed files with 3 additions and 11 deletions

View File

@ -407,9 +407,11 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp)
/*
* 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;

View File

@ -993,16 +993,6 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp)
* 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);
}