Text format cleanups. No functional changes intended.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
This commit is contained in:
Kirk McKusick
2023-07-17 17:28:07 -07:00
parent b24c35b326
commit 239597e030
7 changed files with 62 additions and 54 deletions
+4 -11
View File
@@ -77,7 +77,6 @@ gjournal_check(const char *filesys)
fs = &sblock; fs = &sblock;
/* Are there any unreferenced inodes in this file system? */ /* Are there any unreferenced inodes in this file system? */
if (fs->fs_unrefs == 0) { if (fs->fs_unrefs == 0) {
//printf("No unreferenced inodes.\n");
sbdirty(); sbdirty();
ckfini(1); ckfini(1);
return; return;
@@ -105,7 +104,6 @@ gjournal_check(const char *filesys)
/* Are there any unreferenced inodes in this cylinder group? */ /* Are there any unreferenced inodes in this cylinder group? */
if (cgp->cg_unrefs == 0) if (cgp->cg_unrefs == 0)
continue; continue;
//printf("Analizing cylinder group %d (count=%d)\n", cg, cgp->cg_unrefs);
/* /*
* Now go through the list of all inodes in this cylinder group * Now go through the list of all inodes in this cylinder group
* to find unreferenced ones. * to find unreferenced ones.
@@ -150,21 +148,16 @@ gjournal_check(const char *filesys)
inodirty(&ip); inodirty(&ip);
irelse(&ip); irelse(&ip);
cgdirty(cgbp); cgdirty(cgbp);
if (cgp->cg_unrefs == 0) { if (cgp->cg_unrefs == 0)
//printf("No more unreferenced inodes in cg=%d.\n", cg);
break; break;
} }
}
/* /*
* If there are no more unreferenced inodes, there is no need to * If there are no more unreferenced inodes, there is no
* check other cylinder groups. * need to check other cylinder groups.
*/ */
if (fs->fs_unrefs == 0) { if (fs->fs_unrefs == 0)
//printf("No more unreferenced inodes (cg=%d/%d).\n", cg,
// fs->fs_ncg);
break; break;
} }
}
/* Write back updated statistics and super-block. */ /* Write back updated statistics and super-block. */
sbdirty(); sbdirty();
ckfini(1); ckfini(1);
+12 -12
View File
@@ -60,18 +60,18 @@ ino_t cursnapshot;
long dirhash, inplast; long dirhash, inplast;
unsigned long numdirs, listmax; unsigned long numdirs, listmax;
long countdirs; /* number of directories we actually found */ long countdirs; /* number of directories we actually found */
int adjrefcnt[MIBSIZE]; /* MIB command to adjust inode reference cnt */ int adjrefcnt[MIBSIZE]; /* MIB cmd to adjust inode reference cnt */
int adjblkcnt[MIBSIZE]; /* MIB command to adjust inode block count */ int adjblkcnt[MIBSIZE]; /* MIB cmd to adjust inode block count */
int setsize[MIBSIZE]; /* MIB command to set inode size */ int setsize[MIBSIZE]; /* MIB cmd to set inode size */
int adjndir[MIBSIZE]; /* MIB command to adjust number of directories */ int adjndir[MIBSIZE]; /* MIB cmd to adjust number of directories */
int adjnbfree[MIBSIZE]; /* MIB command to adjust number of free blocks */ int adjnbfree[MIBSIZE]; /* MIB cmd to adjust number of free blocks */
int adjnifree[MIBSIZE]; /* MIB command to adjust number of free inodes */ int adjnifree[MIBSIZE]; /* MIB cmd to adjust number of free inodes */
int adjnffree[MIBSIZE]; /* MIB command to adjust number of free frags */ int adjnffree[MIBSIZE]; /* MIB cmd to adjust number of free frags */
int adjnumclusters[MIBSIZE]; /* MIB command to adjust number of free clusters */ int adjnumclusters[MIBSIZE]; /* MIB cmd to adjust number of free clusters */
int adjdepth[MIBSIZE]; /* MIB cmd to adjust directory depth count */ int adjdepth[MIBSIZE]; /* MIB cmd to adjust directory depth count */
int freefiles[MIBSIZE]; /* MIB command to free a set of files */ int freefiles[MIBSIZE]; /* MIB cmd to free a set of files */
int freedirs[MIBSIZE]; /* MIB command to free a set of directories */ int freedirs[MIBSIZE]; /* MIB cmd to free a set of directories */
int freeblks[MIBSIZE]; /* MIB command to free a set of data blocks */ int freeblks[MIBSIZE]; /* MIB cmd to free a set of data blocks */
struct fsck_cmd cmd; /* sysctl file system update commands */ struct fsck_cmd cmd; /* sysctl file system update commands */
char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */ char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */
char *cdevname; /* name of device being checked */ char *cdevname; /* name of device being checked */
@@ -91,7 +91,7 @@ char ckclean; /* only do work if not cleanly unmounted */
int cvtlevel; /* convert to newer file system format */ int cvtlevel; /* convert to newer file system format */
int ckhashadd; /* check hashes to be added */ int ckhashadd; /* check hashes to be added */
int bkgrdcheck; /* determine if background check is possible */ int bkgrdcheck; /* determine if background check is possible */
int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */ int bkgrdsumadj; /* kernel able to adjust superblock summary */
char usedsoftdep; /* just fix soft dependency inconsistencies */ char usedsoftdep; /* just fix soft dependency inconsistencies */
char preen; /* just fix normal inconsistencies */ char preen; /* just fix normal inconsistencies */
char rerun; /* rerun fsck. Only used in non-preen mode */ char rerun; /* rerun fsck. Only used in non-preen mode */
+5 -3
View File
@@ -351,16 +351,18 @@ checkfilesys(char *filesys)
* Determine if we can and should do journal recovery. * Determine if we can and should do journal recovery.
*/ */
if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) { if ((sblock.fs_flags & FS_SUJ) == FS_SUJ) {
if ((sblock.fs_flags & FS_NEEDSFSCK) != FS_NEEDSFSCK && skipclean) { if ((sblock.fs_flags & FS_NEEDSFSCK) != FS_NEEDSFSCK &&
skipclean) {
sujrecovery = 1; sujrecovery = 1;
if (suj_check(filesys) == 0) { if (suj_check(filesys) == 0) {
printf("\n***** FILE SYSTEM MARKED CLEAN *****\n"); pwarn("\n**** FILE SYSTEM MARKED CLEAN ****\n");
if (chkdoreload(mntp, pwarn) == 0) if (chkdoreload(mntp, pwarn) == 0)
exit(0); exit(0);
exit(4); exit(4);
} }
sujrecovery = 0; sujrecovery = 0;
printf("** Skipping journal, falling through to full fsck\n\n"); pwarn("Skipping journal, "
"falling through to full fsck\n");
} }
if (fswritefd != -1) { if (fswritefd != -1) {
/* /*
+1 -1
View File
@@ -104,7 +104,7 @@ pass1(void)
if (!reply("REBUILD CYLINDER GROUP")) { if (!reply("REBUILD CYLINDER GROUP")) {
cgheader_corrupt = 1; cgheader_corrupt = 1;
if (!nflag) { if (!nflag) {
printf("YOU WILL NEED TO RERUN FSCK.\n"); pwarn("YOU WILL NEED TO RERUN FSCK.\n");
rerun = 1; rerun = 1;
} }
} else { } else {
+22 -12
View File
@@ -411,43 +411,53 @@ pass5(void)
printf("adjndir by %+" PRIi64 "\n", cmd.value); printf("adjndir by %+" PRIi64 "\n", cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjndir, MIBSIZE, 0, 0, if (bkgrdsumadj == 0 || sysctl(adjndir, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1) &cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF DIRECTORIES", cmd.value); rwerror("ADJUST NUMBER OF DIRECTORIES",
cmd.value);
} }
cmd.value = cstotal.cs_nbfree - fs->fs_cstotal.cs_nbfree; cmd.value = cstotal.cs_nbfree - fs->fs_cstotal.cs_nbfree;
if (cmd.value != 0) { if (cmd.value != 0) {
if (debug) if (debug)
printf("adjnbfree by %+" PRIi64 "\n", cmd.value); printf("adjnbfree by %+" PRIi64 "\n",
cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjnbfree, MIBSIZE, 0, 0, if (bkgrdsumadj == 0 || sysctl(adjnbfree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1) &cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE BLOCKS", cmd.value); rwerror("ADJUST NUMBER OF FREE BLOCKS",
cmd.value);
} }
cmd.value = cstotal.cs_nifree - fs->fs_cstotal.cs_nifree; cmd.value = cstotal.cs_nifree - fs->fs_cstotal.cs_nifree;
if (cmd.value != 0) { if (cmd.value != 0) {
if (debug) if (debug)
printf("adjnifree by %+" PRIi64 "\n", cmd.value); printf("adjnifree by %+" PRIi64 "\n",
cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjnifree, MIBSIZE, 0, 0, if (bkgrdsumadj == 0 || sysctl(adjnifree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1) &cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE INODES", cmd.value); rwerror("ADJUST NUMBER OF FREE INODES",
cmd.value);
} }
cmd.value = cstotal.cs_nffree - fs->fs_cstotal.cs_nffree; cmd.value = cstotal.cs_nffree - fs->fs_cstotal.cs_nffree;
if (cmd.value != 0) { if (cmd.value != 0) {
if (debug) if (debug)
printf("adjnffree by %+" PRIi64 "\n", cmd.value); printf("adjnffree by %+" PRIi64 "\n",
cmd.value);
if (bkgrdsumadj == 0 || sysctl(adjnffree, MIBSIZE, 0, 0, if (bkgrdsumadj == 0 || sysctl(adjnffree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1) &cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE FRAGS", cmd.value); rwerror("ADJUST NUMBER OF FREE FRAGS",
cmd.value);
} }
cmd.value = cstotal.cs_numclusters - fs->fs_cstotal.cs_numclusters; cmd.value = cstotal.cs_numclusters -
fs->fs_cstotal.cs_numclusters;
if (cmd.value != 0) { if (cmd.value != 0) {
if (debug) if (debug)
printf("adjnumclusters by %+" PRIi64 "\n", cmd.value); printf("adjnumclusters by %+" PRIi64 "\n",
if (bkgrdsumadj == 0 || sysctl(adjnumclusters, MIBSIZE, 0, 0, cmd.value);
&cmd, sizeof cmd) == -1) if (bkgrdsumadj == 0 || sysctl(adjnumclusters, MIBSIZE,
rwerror("ADJUST NUMBER OF FREE CLUSTERS", cmd.value); 0, 0, &cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE CLUSTERS",
cmd.value);
} }
} }
} }
+15 -12
View File
@@ -502,7 +502,8 @@ blk_free(ino_t ino, ufs2_daddr_t bno, int mask, int frags)
* deallocate the fragment * deallocate the fragment
*/ */
for (i = 0; i < frags; i++) for (i = 0; i < frags; i++)
if ((mask & (1 << i)) == 0 && isclr(blksfree, cgbno +i)) { if ((mask & (1 << i)) == 0 &&
isclr(blksfree, cgbno +i)) {
freefrags++; freefrags++;
setbit(blksfree, cgbno + i); setbit(blksfree, cgbno + i);
} }
@@ -1304,8 +1305,8 @@ ino_trunc(ino_t ino, off_t size)
return; return;
} }
if (debug) if (debug)
printf("Truncating ino %ju, mode %o to size %jd from size %jd\n", printf("Truncating ino %ju, mode %o to size %jd from "
(uintmax_t)ino, mode, size, cursize); "size %jd\n", (uintmax_t)ino, mode, size, cursize);
/* Skip datablocks for short links and devices. */ /* Skip datablocks for short links and devices. */
if (mode == 0 || mode == IFBLK || mode == IFCHR || if (mode == 0 || mode == IFBLK || mode == IFCHR ||
@@ -1511,8 +1512,8 @@ blk_check(struct suj_blk *sblk)
sino->si_blkadj = 1; sino->si_blkadj = 1;
} }
if (debug) if (debug)
printf("op %d blk %jd ino %ju lbn %jd frags %d isat %d (%d)\n", printf("op %d blk %jd ino %ju lbn %jd frags %d isat %d "
brec->jb_op, blk, (uintmax_t)brec->jb_ino, "(%d)\n", brec->jb_op, blk, (uintmax_t)brec->jb_ino,
brec->jb_lbn, brec->jb_frags, isat, frags); brec->jb_lbn, brec->jb_frags, isat, frags);
/* /*
* If we found the block at this address we still have to * If we found the block at this address we still have to
@@ -2335,8 +2336,8 @@ suj_read(void)
recsize <= fs->fs_bsize) recsize <= fs->fs_bsize)
goto restart; goto restart;
if (debug) if (debug)
printf("Found invalid segsize %d > %d\n", printf("Found invalid segsize "
recsize, size); "%d > %d\n", recsize, size);
recsize = real_dev_bsize; recsize = real_dev_bsize;
jblocks_advance(suj_jblocks, recsize); jblocks_advance(suj_jblocks, recsize);
continue; continue;
@@ -2479,7 +2480,8 @@ suj_check(const char *filesys)
cg_apply(cg_adj_blk); cg_apply(cg_adj_blk);
cg_apply(cg_check_ino); cg_apply(cg_check_ino);
} }
if (preen == 0 && (jrecs > 0 || jbytes > 0) && reply("WRITE CHANGES") == 0) if (preen == 0 && (jrecs > 0 || jbytes > 0) &&
reply("WRITE CHANGES") == 0)
return (0); return (0);
/* /*
* Check block counts of snapshot inodes and * Check block counts of snapshot inodes and
@@ -2507,10 +2509,11 @@ suj_check(const char *filesys)
sbdirty(); sbdirty();
ckfini(1); ckfini(1);
if (jrecs > 0 || jbytes > 0) { if (jrecs > 0 || jbytes > 0) {
printf("** %jd journal records in %jd bytes for %.2f%% utilization\n", printf("** %jd journal records in %jd bytes for %.2f%% "
jrecs, jbytes, ((float)jrecs / (float)(jbytes / JREC_SIZE)) * 100); "utilization\n", jrecs, jbytes,
printf("** Freed %jd inodes (%jd dirs) %jd blocks, and %jd frags.\n", ((float)jrecs / (float)(jbytes / JREC_SIZE)) * 100);
freeinos, freedir, freeblocks, freefrags); printf("** Freed %jd inodes (%jd dirs) %jd blocks, and %jd "
"frags.\n", freeinos, freedir, freeblocks, freefrags);
} }
return (0); return (0);