From owner-cvs-all@FreeBSD.ORG Tue Apr 6 12:03:01 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A968216A4CE for ; Tue, 6 Apr 2004 12:03:01 -0700 (PDT) Received: from root.org (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 958E743D2D for ; Tue, 6 Apr 2004 12:03:01 -0700 (PDT) (envelope-from nate@root.org) Received: (qmail 28874 invoked by uid 1000); 6 Apr 2004 18:55:22 -0000 Date: Tue, 6 Apr 2004 11:55:22 -0700 (PDT) From: Nate Lawson To: Lukas Ertl In-Reply-To: <20040406204024.X631@korben> Message-ID: <20040406114524.O28713@root.org> References: <200404031740.i33HeKH6016345@repoman.freebsd.org> <20040403184246.GA613@darkness.comp.waw.pl> <20040406194620.P631@korben> <20040406113129.T28582@root.org> <20040406204024.X631@korben> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: Pawel Jakub Dawidek cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sbin/growfs Makefile debug.c growfs.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2004 19:03:01 -0000 On Tue, 6 Apr 2004, Lukas Ertl wrote: > On Tue, 6 Apr 2004, Nate Lawson wrote: > > > On Tue, 6 Apr 2004, Lukas Ertl wrote: > > > On Sat, 3 Apr 2004, Pawel Jakub Dawidek wrote: > > > > > > > On Sat, Apr 03, 2004 at 09:40:20AM -0800, Lukas Ertl wrote: > > > > +> > > > > +> Modified files: > > > > +> sbin/growfs Makefile debug.c growfs.c > > > > +> Log: > > > > +> Make growfs WARNS=6 clean. > > > > > > > > AFAIK growfs(8) doesn't work with UFS2, so maybe while you are here... :) > > > > > > It works on UFS2, but not very well. Yes, I'll have a look, but maybe > > > I'll make a big style sweep first, so I can actually read what's going on > > > there. :-) > > > > It does work but there are problems. First thing that should be done is > > factor out the superblock update code and have growfs bring it up to > > canonical (latest) form before processing the fs. Also, there are minor > > things like it removing flags like ACLs from the superblock. > > Do you still have the patches you talked about floating around? 1. Factor out ffs_oldfscompat_read and ffs_oldfscompat_write to a .c (ffs_sb.c?) 2. Make it compile in userland (!_KERNEL) case. 3. Compile it into growfs (as appropriate, move into libufs) You'll want to change rdfs and wtfs to use a byte offset instead of a block offset because the newest sb form uses that. This diff also fixes the fs_flags update to only kill the clean/fsck flags but preserve the others. This diff is not complete and was only a start to the experiment. Contact mckusick@ for more info on this approach. ffs_sb.c: #include #include #include /* * Sanity checks for loading old filesystem superblocks. * See ffs_oldfscompat_write below for unwound actions. * * fs is a pointer to the superblock to update, savedmaxfilesize indicates * an area to store the maxfilesize for ffs_oldfscompat_write(), and sblockloc * is the offset of the sblock in bytes. */ void ffs_oldfscompat_read(struct fs *fs, int64_t *savedmaxfilesize, ufs2_daddr_t sblockloc) { ... } /* * Unwinding superblock updates for old filesystems. * See ffs_oldfscompat_read above for details. */ void ffs_oldfscompat_write(struct fs *fs, int64_t maxfilesize) { ... } Diffs: diff -u -r1.13 growfs.c --- /home/nate/freebsd/growfs.old/growfs.c 30 Dec 2002 21:18:05 -0000 1.13 +++ /home/nate/freebsd/growfs.old/growfs.c 4 Apr 2003 16:54:31 -0000 @@ -299,7 +299,7 @@ * Now write the new superblock back to disk. */ sblock.fs_time = utime; - wtfs(sblockloc, (size_t)SBLOCKSIZE, (void *)&sblock, fso, Nflag); + wtfs(sblockloc / DEV_BSIZE, SBLOCKSIZE, &sblock, fso, Nflag); DBG_PRINT0("sblock written\n"); DBG_DUMP_FS(&sblock, "new initial sblock"); @@ -313,7 +313,8 @@ sblock.fs_cgrotor = 0; sblock.fs_state = 0; memset((void *)&sblock.fs_fsmnt, 0, sizeof(sblock.fs_fsmnt)); - sblock.fs_flags &= FS_DOSOFTDEP; + sblock.fs_flags &= ~(FS_UNCLEAN | FS_NEEDSFSCK); + sblock.fs_old_flags = sblock.fs_flags & 0xff; /* * XXX @@ -326,6 +327,7 @@ * fs_minfree, * fs_optim * fs_flags regarding SOFTPDATES + * fs_old_flags * * We probably should rather change the summary for the cylinder group * statistics here to the value of what would be in there, if the file @@ -363,7 +365,7 @@ { DBG_FUNC("initcg") static caddr_t iobuf; - long i, j, d, dlower, dupper, blkno, start; + long i, d, dlower, dupper, blkno, start; ufs2_daddr_t cbase, dmax; struct ufs1_dinode *dp1; struct ufs2_dinode *dp2; @@ -440,6 +442,9 @@ dp1 = (struct ufs1_dinode *)iobuf; dp2 = (struct ufs2_dinode *)iobuf; #ifdef FSIRAND + { + int j; + for (j = 0; j < INOPB(&sblock); j++) if (sblock.fs_magic == FS_UFS1_MAGIC) { dp1->di_gen = random(); @@ -448,6 +453,7 @@ dp2->di_gen = random(); dp2++; } + } #endif wtfs(fsbtodb(&sblock, cgimin(&sblock, cylno) + i), sblock.fs_bsize, iobuf, fso, Nflag); @@ -1494,7 +1500,7 @@ */ for(i=0; isblock.fs_frag)) { - warnx("error: %d refs found for block %d.", + warnx("error: %d refs found for block %jd.", bp[i].found, bp[i].old); } @@ -2042,18 +2048,20 @@ /* * Read the current superblock, and take a backup. + * sblockloc is now always in units of bytes, not blocks */ for (i = 0; sblock_try[i] != -1; i++) { - sblockloc = sblock_try[i] / DEV_BSIZE; - rdfs(sblockloc, (size_t)SBLOCKSIZE, (void *)&(osblock), fsi); + sblockloc = sblock_try[i]; + rdfs(sblockloc / DEV_BSIZE, SBLOCKSIZE, &osblock, fsi); if ((osblock.fs_magic == FS_UFS1_MAGIC || (osblock.fs_magic == FS_UFS2_MAGIC && - osblock.fs_sblockloc == sblock_try[i])) && + (osblock.fs_sblockloc == sblockloc || + (osblock.fs_old_flags & FS_FLAGS_UPDATED) == 0))) && osblock.fs_bsize <= MAXBSIZE && osblock.fs_bsize >= sizeof(struct fs)) break; } - if (sblock_try[i] == -1) { + if (sblock_try[i] == -1 || osblock.fs_sbsize < SBLOCKSIZE) { errx(1, "superblock not recognized"); } memcpy((void *)&fsun1, (void *)&fsun2, sizeof(fsun2)); @@ -2114,7 +2122,7 @@ } } - printf("new file systemsize is: %d frags\n", sblock.fs_size); + printf("new file systemsize is: %jd frags\n", sblock.fs_size); /* * Try to access our new last block in the file system. Even if we @@ -2156,7 +2164,7 @@ sblock.fs_ncg--; if (sblock.fs_magic == FS_UFS1_MAGIC) sblock.fs_old_ncyl = sblock.fs_ncg * sblock.fs_old_cpg; - printf("Warning: %d sector(s) cannot be allocated.\n", + printf("Warning: %jd sector(s) cannot be allocated.\n", fsbtodb(&sblock, sblock.fs_size % sblock.fs_fpg)); sblock.fs_size = sblock.fs_ncg * sblock.fs_fpg; } @@ -2340,7 +2348,7 @@ ufs_lbn_t len, lbn, numblks; ufs2_daddr_t iptr, blksperindir; union dinode *ino; - int i, mode, remaining_blocks, inodeupdated; + int i, mode, inodeupdated; DBG_ENTER; @@ -2420,7 +2428,6 @@ { DBG_FUNC("indirchk") void *ibuf; - off_t offset; int i, last; ufs2_daddr_t iptr;