svn commit: r252435 - in head/sys/ufs: ffs ufs

Pedro F. Giffuni pfg at FreeBSD.org
Mon Jul 1 03:00:17 UTC 2013


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.
  
  In UFS, i_gen is a random generated value and there is not way for
  it to be negative. Actually, the value of i_gen is just used to
  match bit patterns and it is of not consequence if the values are
  signed or not.
  
  Following other filesystems, set it to unsigned and use it as such,
  
  Discussed by:	mckusick
  Reviewed by:	mckusick (previous version)
  MFC after:	4 weeks

Modified:
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ufs/dinode.h
  head/sys/ufs/ufs/inode.h
  head/sys/ufs/ufs/ufs_extattr.c

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);

Modified: head/sys/ufs/ufs/dinode.h
==============================================================================
--- head/sys/ufs/ufs/dinode.h	Mon Jul  1 02:48:27 2013	(r252434)
+++ head/sys/ufs/ufs/dinode.h	Mon Jul  1 03:00:15 2013	(r252435)
@@ -138,7 +138,7 @@ struct ufs2_dinode {
 	int32_t		di_atimensec;	/*  68: Last access time. */
 	int32_t		di_ctimensec;	/*  72: Last inode change time. */
 	int32_t		di_birthnsec;	/*  76: Inode creation time. */
-	int32_t		di_gen;		/*  80: Generation number. */
+	u_int32_t	di_gen;		/*  80: Generation number. */
 	u_int32_t	di_kernflags;	/*  84: Kernel flags. */
 	u_int32_t	di_flags;	/*  88: Status flags (chflags). */
 	int32_t		di_extsize;	/*  92: External attributes block. */
@@ -180,7 +180,7 @@ struct ufs1_dinode {
 	ufs1_daddr_t	di_ib[NIADDR];	/*  88: Indirect disk blocks. */
 	u_int32_t	di_flags;	/* 100: Status flags (chflags). */
 	int32_t		di_blocks;	/* 104: Blocks actually held. */
-	int32_t		di_gen;		/* 108: Generation number. */
+	u_int32_t	di_gen;		/* 108: Generation number. */
 	u_int32_t	di_uid;		/* 112: File owner. */
 	u_int32_t	di_gid;		/* 116: File group. */
 	u_int64_t	di_modrev;	/* 120: i_modrev for NFSv4 */

Modified: head/sys/ufs/ufs/inode.h
==============================================================================
--- head/sys/ufs/ufs/inode.h	Mon Jul  1 02:48:27 2013	(r252434)
+++ head/sys/ufs/ufs/inode.h	Mon Jul  1 03:00:15 2013	(r252435)
@@ -102,7 +102,7 @@ struct inode {
 	int16_t	  i_nlink;	/* File link count. */
 	u_int64_t i_size;	/* File byte count. */
 	u_int32_t i_flags;	/* Status flags (chflags). */
-	int64_t	  i_gen;	/* Generation number. */
+	u_int64_t i_gen;	/* Generation number. */
 	u_int32_t i_uid;	/* File owner. */
 	u_int32_t i_gid;	/* File group. */
 	/*

Modified: head/sys/ufs/ufs/ufs_extattr.c
==============================================================================
--- head/sys/ufs/ufs/ufs_extattr.c	Mon Jul  1 02:48:27 2013	(r252434)
+++ head/sys/ufs/ufs/ufs_extattr.c	Mon Jul  1 03:00:15 2013	(r252435)
@@ -935,7 +935,7 @@ ufs_extattr_get(struct vnode *vp, int at
 		 * up by the next write or extattrctl clean.
 		 */
 		printf("ufs_extattr_get (%s): inode number inconsistency (%d, %jd)\n",
-		    mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (intmax_t)ip->i_gen);
+		    mp->mnt_stat.f_mntonname, ueh.ueh_i_gen, (uintmax_t)ip->i_gen);
 		error = ENOATTR;
 		goto vopunlock_exit;
 	}


More information about the svn-src-head mailing list