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:
parent
537f1d275f
commit
43ce40e891
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user