pass5.c revision 70050
11558Srgrimes/*
21558Srgrimes * Copyright (c) 1980, 1986, 1993
31558Srgrimes *	The Regents of the University of California.  All rights reserved.
41558Srgrimes *
51558Srgrimes * Redistribution and use in source and binary forms, with or without
61558Srgrimes * modification, are permitted provided that the following conditions
71558Srgrimes * are met:
81558Srgrimes * 1. Redistributions of source code must retain the above copyright
91558Srgrimes *    notice, this list of conditions and the following disclaimer.
101558Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111558Srgrimes *    notice, this list of conditions and the following disclaimer in the
121558Srgrimes *    documentation and/or other materials provided with the distribution.
131558Srgrimes * 3. All advertising materials mentioning features or use of this software
141558Srgrimes *    must display the following acknowledgement:
151558Srgrimes *	This product includes software developed by the University of
161558Srgrimes *	California, Berkeley and its contributors.
171558Srgrimes * 4. Neither the name of the University nor the names of its contributors
181558Srgrimes *    may be used to endorse or promote products derived from this software
191558Srgrimes *    without specific prior written permission.
201558Srgrimes *
211558Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221558Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241558Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251558Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261558Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271558Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281558Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291558Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301558Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311558Srgrimes * SUCH DAMAGE.
321558Srgrimes */
331558Srgrimes
341558Srgrimes#ifndef lint
3541477Sjulian#if 0
3623675Speterstatic const char sccsid[] = "@(#)pass5.c	8.9 (Berkeley) 4/28/95";
3741477Sjulian#endif
3841477Sjulianstatic const char rcsid[] =
3950476Speter  "$FreeBSD: head/sbin/fsck_ffs/pass5.c 70050 2000-12-15 14:23:55Z iedowse $";
401558Srgrimes#endif /* not lint */
411558Srgrimes
421558Srgrimes#include <sys/param.h>
4323675Speter
441558Srgrimes#include <ufs/ufs/dinode.h>
451558Srgrimes#include <ufs/ffs/fs.h>
4623799Sbde
4723675Speter#include <err.h>
481558Srgrimes#include <string.h>
4923675Speter
501558Srgrimes#include "fsck.h"
511558Srgrimes
527585Sbdevoid
531558Srgrimespass5()
541558Srgrimes{
5541474Sjulian	int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
5662668Smckusick	int inomapsize, blkmapsize, astart, aend, ustart, uend;
5723675Speter	struct fs *fs = &sblock;
5823675Speter	struct cg *cg = &cgrp;
5923675Speter	ufs_daddr_t dbase, dmax;
6023675Speter	ufs_daddr_t d;
6162668Smckusick	long i, j, k, l, m, n;
621558Srgrimes	struct csum *cs;
631558Srgrimes	struct csum cstotal;
641558Srgrimes	struct inodesc idesc[3];
651558Srgrimes	char buf[MAXBSIZE];
661558Srgrimes	register struct cg *newcg = (struct cg *)buf;
671558Srgrimes	struct ocg *ocg = (struct ocg *)buf;
681558Srgrimes
6941474Sjulian	inoinfo(WINO)->ino_state = USTATE;
7023675Speter	memset(newcg, 0, (size_t)fs->fs_cgsize);
711558Srgrimes	newcg->cg_niblk = fs->fs_ipg;
7223675Speter	if (cvtlevel >= 3) {
731558Srgrimes		if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) {
741558Srgrimes			if (preen)
751558Srgrimes				pwarn("DELETING CLUSTERING MAPS\n");
761558Srgrimes			if (preen || reply("DELETE CLUSTERING MAPS")) {
771558Srgrimes				fs->fs_contigsumsize = 0;
781558Srgrimes				doinglevel1 = 1;
791558Srgrimes				sbdirty();
801558Srgrimes			}
811558Srgrimes		}
821558Srgrimes		if (fs->fs_maxcontig > 1) {
831558Srgrimes			char *doit = 0;
841558Srgrimes
851558Srgrimes			if (fs->fs_contigsumsize < 1) {
861558Srgrimes				doit = "CREAT";
871558Srgrimes			} else if (fs->fs_contigsumsize < fs->fs_maxcontig &&
881558Srgrimes				   fs->fs_contigsumsize < FS_MAXCONTIG) {
891558Srgrimes				doit = "EXPAND";
901558Srgrimes			}
911558Srgrimes			if (doit) {
921558Srgrimes				i = fs->fs_contigsumsize;
931558Srgrimes				fs->fs_contigsumsize =
941558Srgrimes				    MIN(fs->fs_maxcontig, FS_MAXCONTIG);
951558Srgrimes				if (CGSIZE(fs) > fs->fs_bsize) {
961558Srgrimes					pwarn("CANNOT %s CLUSTER MAPS\n", doit);
971558Srgrimes					fs->fs_contigsumsize = i;
981558Srgrimes				} else if (preen ||
991558Srgrimes				    reply("CREATE CLUSTER MAPS")) {
1001558Srgrimes					if (preen)
1011558Srgrimes						pwarn("%sING CLUSTER MAPS\n",
1021558Srgrimes						    doit);
1031558Srgrimes					fs->fs_cgsize =
1041558Srgrimes					    fragroundup(fs, CGSIZE(fs));
1051558Srgrimes					doinglevel1 = 1;
1061558Srgrimes					sbdirty();
1071558Srgrimes				}
1081558Srgrimes			}
1091558Srgrimes		}
1101558Srgrimes	}
1111558Srgrimes	switch ((int)fs->fs_postblformat) {
1121558Srgrimes
1131558Srgrimes	case FS_42POSTBLFMT:
11423675Speter		basesize = (char *)(&ocg->cg_btot[0]) -
11523675Speter		    (char *)(&ocg->cg_firstfield);
11623675Speter		sumsize = &ocg->cg_iused[0] - (u_int8_t *)(&ocg->cg_btot[0]);
1171558Srgrimes		mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] -
1181558Srgrimes			(u_char *)&ocg->cg_iused[0];
11934266Sjulian		blkmapsize = howmany(fs->fs_fpg, NBBY);
12034266Sjulian		inomapsize = &ocg->cg_free[0] - (u_char *)&ocg->cg_iused[0];
1211558Srgrimes		ocg->cg_magic = CG_MAGIC;
1221558Srgrimes		savednrpos = fs->fs_nrpos;
1231558Srgrimes		fs->fs_nrpos = 8;
1241558Srgrimes		break;
1251558Srgrimes
1261558Srgrimes	case FS_DYNAMICPOSTBLFMT:
1271558Srgrimes		newcg->cg_btotoff =
12823675Speter		     &newcg->cg_space[0] - (u_char *)(&newcg->cg_firstfield);
1291558Srgrimes		newcg->cg_boff =
13038328Sdfr		    newcg->cg_btotoff + fs->fs_cpg * sizeof(int32_t);
1318871Srgrimes		newcg->cg_iusedoff = newcg->cg_boff +
13238328Sdfr		    fs->fs_cpg * fs->fs_nrpos * sizeof(u_int16_t);
1331558Srgrimes		newcg->cg_freeoff =
1341558Srgrimes		    newcg->cg_iusedoff + howmany(fs->fs_ipg, NBBY);
13534266Sjulian		inomapsize = newcg->cg_freeoff - newcg->cg_iusedoff;
13634266Sjulian		newcg->cg_nextfreeoff = newcg->cg_freeoff +
13734266Sjulian		    howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY);
13834266Sjulian		blkmapsize = newcg->cg_nextfreeoff - newcg->cg_freeoff;
13934266Sjulian		if (fs->fs_contigsumsize > 0) {
14034266Sjulian			newcg->cg_clustersumoff = newcg->cg_nextfreeoff -
14138328Sdfr			    sizeof(u_int32_t);
1421558Srgrimes			newcg->cg_clustersumoff =
14338328Sdfr			    roundup(newcg->cg_clustersumoff, sizeof(u_int32_t));
1441558Srgrimes			newcg->cg_clusteroff = newcg->cg_clustersumoff +
14538328Sdfr			    (fs->fs_contigsumsize + 1) * sizeof(u_int32_t);
1461558Srgrimes			newcg->cg_nextfreeoff = newcg->cg_clusteroff +
1471558Srgrimes			    howmany(fs->fs_cpg * fs->fs_spc / NSPB(fs), NBBY);
1481558Srgrimes		}
1491558Srgrimes		newcg->cg_magic = CG_MAGIC;
15023675Speter		basesize = &newcg->cg_space[0] -
15123675Speter		    (u_char *)(&newcg->cg_firstfield);
1521558Srgrimes		sumsize = newcg->cg_iusedoff - newcg->cg_btotoff;
1531558Srgrimes		mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff;
1541558Srgrimes		break;
1551558Srgrimes
1561558Srgrimes	default:
15734266Sjulian		inomapsize = blkmapsize = sumsize = 0;	/* keep lint happy */
15823675Speter		errx(EEXIT, "UNKNOWN ROTATIONAL TABLE FORMAT %d",
1591558Srgrimes			fs->fs_postblformat);
1601558Srgrimes	}
16123675Speter	memset(&idesc[0], 0, sizeof idesc);
1621558Srgrimes	for (i = 0; i < 3; i++) {
1631558Srgrimes		idesc[i].id_type = ADDR;
1641558Srgrimes		if (doinglevel2)
1651558Srgrimes			idesc[i].id_fix = FIX;
1661558Srgrimes	}
16723675Speter	memset(&cstotal, 0, sizeof(struct csum));
1681558Srgrimes	j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
1691558Srgrimes	for (i = fs->fs_size; i < j; i++)
1701558Srgrimes		setbmap(i);
1711558Srgrimes	for (c = 0; c < fs->fs_ncg; c++) {
17270050Siedowse		if (got_siginfo) {
17370050Siedowse			printf("%s: phase 5: cyl group %d of %d (%d%%)\n",
17470050Siedowse			    cdevname, c, sblock.fs_ncg,
17570050Siedowse			    c * 100 / sblock.fs_ncg);
17670050Siedowse			got_siginfo = 0;
17770050Siedowse		}
1781558Srgrimes		getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
1791558Srgrimes		if (!cg_chkmagic(cg))
1801558Srgrimes			pfatal("CG %d: BAD MAGIC NUMBER\n", c);
1811558Srgrimes		dbase = cgbase(fs, c);
1821558Srgrimes		dmax = dbase + fs->fs_fpg;
1831558Srgrimes		if (dmax > fs->fs_size)
1841558Srgrimes			dmax = fs->fs_size;
1851558Srgrimes		newcg->cg_time = cg->cg_time;
1861558Srgrimes		newcg->cg_cgx = c;
1871558Srgrimes		if (c == fs->fs_ncg - 1)
1881558Srgrimes			newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg;
1891558Srgrimes		else
1901558Srgrimes			newcg->cg_ncyl = fs->fs_cpg;
1911558Srgrimes		newcg->cg_ndblk = dmax - dbase;
1921558Srgrimes		if (fs->fs_contigsumsize > 0)
1931558Srgrimes			newcg->cg_nclusterblks = newcg->cg_ndblk / fs->fs_frag;
1941558Srgrimes		newcg->cg_cs.cs_ndir = 0;
1951558Srgrimes		newcg->cg_cs.cs_nffree = 0;
1961558Srgrimes		newcg->cg_cs.cs_nbfree = 0;
1971558Srgrimes		newcg->cg_cs.cs_nifree = fs->fs_ipg;
1981558Srgrimes		if (cg->cg_rotor < newcg->cg_ndblk)
1991558Srgrimes			newcg->cg_rotor = cg->cg_rotor;
2001558Srgrimes		else
2011558Srgrimes			newcg->cg_rotor = 0;
2021558Srgrimes		if (cg->cg_frotor < newcg->cg_ndblk)
2031558Srgrimes			newcg->cg_frotor = cg->cg_frotor;
2041558Srgrimes		else
2051558Srgrimes			newcg->cg_frotor = 0;
2061558Srgrimes		if (cg->cg_irotor < newcg->cg_niblk)
2071558Srgrimes			newcg->cg_irotor = cg->cg_irotor;
2081558Srgrimes		else
2091558Srgrimes			newcg->cg_irotor = 0;
21023675Speter		memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum);
21123675Speter		memset(&cg_blktot(newcg)[0], 0,
2121558Srgrimes		      (size_t)(sumsize + mapsize));
2131558Srgrimes		if (fs->fs_postblformat == FS_42POSTBLFMT)
2141558Srgrimes			ocg->cg_magic = CG_MAGIC;
2151558Srgrimes		j = fs->fs_ipg * c;
21641474Sjulian		for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
21741474Sjulian			switch (inoinfo(j)->ino_state) {
2181558Srgrimes
2191558Srgrimes			case USTATE:
2201558Srgrimes				break;
2211558Srgrimes
2221558Srgrimes			case DSTATE:
2231558Srgrimes			case DCLEAR:
2241558Srgrimes			case DFOUND:
2251558Srgrimes				newcg->cg_cs.cs_ndir++;
2261558Srgrimes				/* fall through */
2271558Srgrimes
2281558Srgrimes			case FSTATE:
2291558Srgrimes			case FCLEAR:
2301558Srgrimes				newcg->cg_cs.cs_nifree--;
2311558Srgrimes				setbit(cg_inosused(newcg), i);
2321558Srgrimes				break;
2331558Srgrimes
2341558Srgrimes			default:
2351558Srgrimes				if (j < ROOTINO)
2361558Srgrimes					break;
23737236Sbde				errx(EEXIT, "BAD STATE %d FOR INODE I=%ld",
23841474Sjulian				    inoinfo(j)->ino_state, j);
2391558Srgrimes			}
2401558Srgrimes		}
2411558Srgrimes		if (c == 0)
2421558Srgrimes			for (i = 0; i < ROOTINO; i++) {
2431558Srgrimes				setbit(cg_inosused(newcg), i);
2441558Srgrimes				newcg->cg_cs.cs_nifree--;
2451558Srgrimes			}
2461558Srgrimes		for (i = 0, d = dbase;
2471558Srgrimes		     d < dmax;
2481558Srgrimes		     d += fs->fs_frag, i += fs->fs_frag) {
2491558Srgrimes			frags = 0;
2501558Srgrimes			for (j = 0; j < fs->fs_frag; j++) {
2511558Srgrimes				if (testbmap(d + j))
2521558Srgrimes					continue;
2531558Srgrimes				setbit(cg_blksfree(newcg), i + j);
2541558Srgrimes				frags++;
2551558Srgrimes			}
2561558Srgrimes			if (frags == fs->fs_frag) {
2571558Srgrimes				newcg->cg_cs.cs_nbfree++;
2581558Srgrimes				j = cbtocylno(fs, i);
2591558Srgrimes				cg_blktot(newcg)[j]++;
2601558Srgrimes				cg_blks(fs, newcg, j)[cbtorpos(fs, i)]++;
2611558Srgrimes				if (fs->fs_contigsumsize > 0)
2621558Srgrimes					setbit(cg_clustersfree(newcg),
2631558Srgrimes					    i / fs->fs_frag);
2641558Srgrimes			} else if (frags > 0) {
2651558Srgrimes				newcg->cg_cs.cs_nffree += frags;
2661558Srgrimes				blk = blkmap(fs, cg_blksfree(newcg), i);
2671558Srgrimes				ffs_fragacct(fs, blk, newcg->cg_frsum, 1);
2681558Srgrimes			}
2691558Srgrimes		}
2701558Srgrimes		if (fs->fs_contigsumsize > 0) {
27123675Speter			int32_t *sump = cg_clustersum(newcg);
2721558Srgrimes			u_char *mapp = cg_clustersfree(newcg);
2731558Srgrimes			int map = *mapp++;
2741558Srgrimes			int bit = 1;
2751558Srgrimes			int run = 0;
2761558Srgrimes
2771558Srgrimes			for (i = 0; i < newcg->cg_nclusterblks; i++) {
2781558Srgrimes				if ((map & bit) != 0) {
2791558Srgrimes					run++;
2801558Srgrimes				} else if (run != 0) {
2811558Srgrimes					if (run > fs->fs_contigsumsize)
2821558Srgrimes						run = fs->fs_contigsumsize;
2831558Srgrimes					sump[run]++;
2841558Srgrimes					run = 0;
2851558Srgrimes				}
2861558Srgrimes				if ((i & (NBBY - 1)) != (NBBY - 1)) {
2871558Srgrimes					bit <<= 1;
2881558Srgrimes				} else {
2891558Srgrimes					map = *mapp++;
2901558Srgrimes					bit = 1;
2911558Srgrimes				}
2921558Srgrimes			}
2931558Srgrimes			if (run != 0) {
2941558Srgrimes				if (run > fs->fs_contigsumsize)
2951558Srgrimes					run = fs->fs_contigsumsize;
2961558Srgrimes				sump[run]++;
2971558Srgrimes			}
2981558Srgrimes		}
2991558Srgrimes		cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
3001558Srgrimes		cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree;
3011558Srgrimes		cstotal.cs_nifree += newcg->cg_cs.cs_nifree;
3021558Srgrimes		cstotal.cs_ndir += newcg->cg_cs.cs_ndir;
3031558Srgrimes		cs = &fs->fs_cs(fs, c);
30423675Speter		if (memcmp(&newcg->cg_cs, cs, sizeof *cs) != 0 &&
3051558Srgrimes		    dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
30623675Speter			memmove(cs, &newcg->cg_cs, sizeof *cs);
3071558Srgrimes			sbdirty();
3081558Srgrimes		}
3091558Srgrimes		if (doinglevel1) {
31023675Speter			memmove(cg, newcg, (size_t)fs->fs_cgsize);
3111558Srgrimes			cgdirty();
3121558Srgrimes			continue;
3131558Srgrimes		}
31423675Speter		if ((memcmp(newcg, cg, basesize) != 0 ||
31523675Speter		     memcmp(&cg_blktot(newcg)[0],
31623675Speter			  &cg_blktot(cg)[0], sumsize) != 0) &&
3171558Srgrimes		    dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
31823675Speter			memmove(cg, newcg, (size_t)basesize);
31923675Speter			memmove(&cg_blktot(cg)[0],
32023675Speter			       &cg_blktot(newcg)[0], (size_t)sumsize);
3211558Srgrimes			cgdirty();
3221558Srgrimes		}
32362668Smckusick		if (debug) {
32462668Smckusick			for (i = 0; i < inomapsize; i++) {
32562668Smckusick				j = cg_inosused(newcg)[i];
32662668Smckusick				k = cg_inosused(cg)[i];
32762668Smckusick				if (j == k)
32862668Smckusick					continue;
32962668Smckusick				for (m = 0, l = 1; m < NBBY; m++, l <<= 1) {
33062668Smckusick					if ((j & l) == (k & l))
33162668Smckusick						continue;
33262668Smckusick					n = c * fs->fs_ipg + i * NBBY + m;
33362668Smckusick					if ((j & l) != 0)
33462668Smckusick						pwarn("%s INODE %d MARKED %s\n",
33562668Smckusick						    "ALLOCATED", n, "FREE");
33662668Smckusick					else
33762668Smckusick						pwarn("%s INODE %d MARKED %s\n",
33862668Smckusick						    "UNALLOCATED", n, "USED");
33962668Smckusick				}
34062668Smckusick			}
34162668Smckusick			astart = ustart = -1;
34262668Smckusick			for (i = 0; i < blkmapsize; i++) {
34362668Smckusick				j = cg_blksfree(cg)[i];
34462668Smckusick				k = cg_blksfree(newcg)[i];
34562668Smckusick				if (j == k)
34662668Smckusick					continue;
34762668Smckusick				for (m = 0, l = 1; m < NBBY; m++, l <<= 1) {
34862668Smckusick					if ((j & l) == (k & l))
34962668Smckusick						continue;
35062668Smckusick					n = c * fs->fs_fpg + i * NBBY + m;
35162668Smckusick					if ((j & l) != 0) {
35262668Smckusick						if (astart == -1) {
35362668Smckusick							astart = aend = n;
35462668Smckusick							continue;
35562668Smckusick						}
35662668Smckusick						if (aend + 1 == n) {
35762668Smckusick							aend = n;
35862668Smckusick							continue;
35962668Smckusick						}
36062668Smckusick						pwarn("%s FRAGS %d-%d %s\n",
36162668Smckusick						    "ALLOCATED", astart, aend,
36262668Smckusick						    "MARKED FREE");
36362668Smckusick						astart = aend = n;
36462668Smckusick					} else {
36562668Smckusick						if (ustart == -1) {
36662668Smckusick							ustart = uend = n;
36762668Smckusick							continue;
36862668Smckusick						}
36962668Smckusick						if (uend + 1 == n) {
37062668Smckusick							uend = n;
37162668Smckusick							continue;
37262668Smckusick						}
37362668Smckusick						pwarn("%s FRAGS %d-%d %s\n",
37462668Smckusick						    "UNALLOCATED", ustart, uend,
37562668Smckusick						    "MARKED USED");
37662668Smckusick						ustart = uend = n;
37762668Smckusick					}
37862668Smckusick				}
37962668Smckusick			}
38062668Smckusick			if (astart != -1)
38162668Smckusick				pwarn("%s FRAGS %d-%d %s\n",
38262668Smckusick				    "ALLOCATED", astart, aend,
38362668Smckusick				    "MARKED FREE");
38462668Smckusick			if (ustart != -1)
38562668Smckusick				pwarn("%s FRAGS %d-%d %s\n",
38662668Smckusick				    "UNALLOCATED", ustart, uend,
38762668Smckusick				    "MARKED USED");
38862668Smckusick		}
38934266Sjulian		if (usedsoftdep) {
39034266Sjulian			for (i = 0; i < inomapsize; i++) {
39134266Sjulian				j = cg_inosused(newcg)[i];
39234266Sjulian				if ((cg_inosused(cg)[i] & j) == j)
39334266Sjulian					continue;
39434266Sjulian				for (k = 0; k < NBBY; k++) {
39534266Sjulian					if ((j & (1 << k)) == 0)
39634266Sjulian						continue;
39734266Sjulian					if (cg_inosused(cg)[i] & (1 << k))
39834266Sjulian						continue;
39938067Sphk					pwarn("ALLOCATED INODE %d MARKED FREE\n",
40041474Sjulian					    c * fs->fs_ipg + i * NBBY + k);
40134266Sjulian				}
40234266Sjulian			}
40334266Sjulian			for (i = 0; i < blkmapsize; i++) {
40434266Sjulian				j = cg_blksfree(cg)[i];
40534266Sjulian				if ((cg_blksfree(newcg)[i] & j) == j)
40634266Sjulian					continue;
40734266Sjulian				for (k = 0; k < NBBY; k++) {
40834266Sjulian					if ((j & (1 << k)) == 0)
40934266Sjulian						continue;
41036681Sjulian					if (cg_blksfree(newcg)[i] & (1 << k))
41134266Sjulian						continue;
41238067Sphk					pwarn("ALLOCATED FRAG %d MARKED FREE\n",
41341474Sjulian					    c * fs->fs_fpg + i * NBBY + k);
41434266Sjulian				}
41534266Sjulian			}
41634266Sjulian		}
41734266Sjulian		if (memcmp(cg_inosused(newcg), cg_inosused(cg), mapsize) != 0 &&
41834266Sjulian		    dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
41934266Sjulian			memmove(cg_inosused(cg), cg_inosused(newcg),
42034266Sjulian			      (size_t)mapsize);
42134266Sjulian			cgdirty();
42234266Sjulian		}
4231558Srgrimes	}
4241558Srgrimes	if (fs->fs_postblformat == FS_42POSTBLFMT)
4251558Srgrimes		fs->fs_nrpos = savednrpos;
42623675Speter	if (memcmp(&cstotal, &fs->fs_cstotal, sizeof *cs) != 0
4271558Srgrimes	    && dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
42823675Speter		memmove(&fs->fs_cstotal, &cstotal, sizeof *cs);
4291558Srgrimes		fs->fs_ronly = 0;
43041474Sjulian		fs->fs_fmod = 0;
4311558Srgrimes		sbdirty();
4321558Srgrimes	}
4331558Srgrimes}
434