svn commit: r205261 - stable/6/sbin/growfs

Gavin Atkinson gavin at FreeBSD.org
Wed Mar 17 20:32:14 UTC 2010


Author: gavin
Date: Wed Mar 17 20:32:13 2010
New Revision: 205261
URL: http://svn.freebsd.org/changeset/base/205261

Log:
  Merge r201401 from head:
  
    Remove dead code.  This section of code is only run in the
    (sblock.fs_magic == FS_UFS1_MAGIC) case, so the check within the
    loop is redundant.
  
  Merge 203835 from head:
  
    When growing a UFS1 filesystem, we need to initialise all inodes in any new
    cylinder groups that are created.  When the filesystem is first created,
    newfs always initialises the first two blocks of inodes, and then in the
    UFS1 case will also initialise the remaining inode blocks.  The changes in
    growfs.c 1.23 broke the initialisation of all inodes, seemingly based on
    this implementation detail in newfs(8).  The result was that instead of
    initialising all inodes, we would actually end up initialising all but the
    first two blocks of inodes.  If the filesystem was grown into empty
    (all-zeros) space then the resulting filesystem was fine, however when
    grown onto non-zeroed space the filesystem produced would appear to have
    massive corruption on the first fsck after growing.
    A test case for this problem can be found in the PR audit trail.
  
    Fix this by once again initialising all inodes in the UFS1 case.
  
  PR:		bin/115174
  Submitted by:	"Nate Eldredge" <nge cs.hmc.edu>
  Reviewed by:	mjacob

Modified:
  stable/6/sbin/growfs/growfs.c
Directory Properties:
  stable/6/sbin/growfs/   (props changed)

Modified: stable/6/sbin/growfs/growfs.c
==============================================================================
--- stable/6/sbin/growfs/growfs.c	Wed Mar 17 20:30:37 2010	(r205260)
+++ stable/6/sbin/growfs/growfs.c	Wed Mar 17 20:32:13 2010	(r205261)
@@ -376,7 +376,6 @@ initcg(int cylno, time_t utime, int fso,
 	long d, dlower, dupper, blkno, start;
 	ufs2_daddr_t i, cbase, dmax;
 	struct ufs1_dinode *dp1;
-	struct ufs2_dinode *dp2;
 	struct csum *cs;
 
 	if (iobuf == NULL && (iobuf = malloc(sblock.fs_bsize)) == NULL) {
@@ -446,25 +445,18 @@ initcg(int cylno, time_t utime, int fso,
 			acg.cg_cs.cs_nifree--;
 		}
 	/*
-	 * XXX Newfs writes out two blocks of initialized inodes
-	 *     unconditionally.  Should we check here to make sure that they
-	 *     were actually written?
+	 * For the old file system, we have to initialize all the inodes.
 	 */
 	if (sblock.fs_magic == FS_UFS1_MAGIC) {
 		bzero(iobuf, sblock.fs_bsize);
-		for (i = 2 * sblock.fs_frag; i < sblock.fs_ipg / INOPF(&sblock);
+		for (i = 0; i < sblock.fs_ipg / INOPF(&sblock);
 		     i += sblock.fs_frag) {
 			dp1 = (struct ufs1_dinode *)iobuf;
-			dp2 = (struct ufs2_dinode *)iobuf;
 #ifdef FSIRAND
-			for (j = 0; j < INOPB(&sblock); j++)
-				if (sblock.fs_magic == FS_UFS1_MAGIC) {
-					dp1->di_gen = random();
-					dp1++;
-				} else {
-					dp2->di_gen = random();
-					dp2++;
-				}
+			for (j = 0; j < INOPB(&sblock); j++) {
+				dp1->di_gen = random();
+				dp1++;
+			}
 #endif
 			wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i),
 			    sblock.fs_bsize, iobuf, fso, Nflag);


More information about the svn-src-all mailing list