summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2005-03-07 08:42:49 +0000
committerdelphij <delphij@FreeBSD.org>2005-03-07 08:42:49 +0000
commit50d65e6e8dfe7acfb233acf00aae3c86ad106694 (patch)
tree4a55cc21d650dd93da6eb7cdf52fd17aa3778ba7 /sbin/fsck_ffs
parentd3c3434c1cc5d8a3a7efde19b203447a56837ea0 (diff)
downloadFreeBSD-src-50d65e6e8dfe7acfb233acf00aae3c86ad106694.zip
FreeBSD-src-50d65e6e8dfe7acfb233acf00aae3c86ad106694.tar.gz
Make background fsck based summary adjustments actually work by
initializing the sysctl mibs data before actually using them. The original patchset (which is the actual version that is running on my testboxes) have checked whether all of these sysctls and refuses to do background fsck if we don't have them. Kirk has pointed out that refusing running fsck on old kernels is pointless, as old kernels will recompute the summary at mount time, so I have removed these checks. Unfortunatelly, as the checks will initialize the mib values of those sysctl's, and which are vital for the runtime summary adjustment to work, we can not simply remove the check, which will lead to problem when running background fsck over a dirty volume. Add these checks in a different way: give a warning rather than refusing to work, and complain if the functionality is not available when adjustments are necessary. Noticed by: A power failure at my lab Pointy hat: me MFC After: 3 days
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r--sbin/fsck_ffs/fsck.h1
-rw-r--r--sbin/fsck_ffs/pass5.c10
-rw-r--r--sbin/fsck_ffs/setup.c18
3 files changed, 24 insertions, 5 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 55a57bc..32f9cfa 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -272,6 +272,7 @@ int bflag; /* location of alternate super block */
int debug; /* output debugging info */
int cvtlevel; /* convert to newer file system format */
int bkgrdcheck; /* determine if background check is possible */
+int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */
char usedsoftdep; /* just fix soft dependency inconsistencies */
char preen; /* just fix normal inconsistencies */
char rerun; /* rerun fsck. Only used in non-preen mode */
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 796b546..693831f 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -358,7 +358,7 @@ pass5(void)
if (cmd.value != 0) {
if (debug)
printf("adjndir by %+" PRIi64 "\n", cmd.value);
- if (sysctl(adjndir, MIBSIZE, 0, 0,
+ if (bkgrdsumadj == 0 || sysctl(adjndir, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF DIRECTORIES", cmd.value);
}
@@ -367,7 +367,7 @@ pass5(void)
if (cmd.value != 0) {
if (debug)
printf("adjnbfree by %+" PRIi64 "\n", cmd.value);
- if (sysctl(adjnbfree, MIBSIZE, 0, 0,
+ if (bkgrdsumadj == 0 || sysctl(adjnbfree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE BLOCKS", cmd.value);
}
@@ -376,7 +376,7 @@ pass5(void)
if (cmd.value != 0) {
if (debug)
printf("adjnifree by %+" PRIi64 "\n", cmd.value);
- if (sysctl(adjnifree, MIBSIZE, 0, 0,
+ if (bkgrdsumadj == 0 || sysctl(adjnifree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE INODES", cmd.value);
}
@@ -385,7 +385,7 @@ pass5(void)
if (cmd.value != 0) {
if (debug)
printf("adjnffree by %+" PRIi64 "\n", cmd.value);
- if (sysctl(adjnffree, MIBSIZE, 0, 0,
+ if (bkgrdsumadj == 0 || sysctl(adjnffree, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE FRAGS", cmd.value);
}
@@ -394,7 +394,7 @@ pass5(void)
if (cmd.value != 0) {
if (debug)
printf("adjnumclusters by %+" PRIi64 "\n", cmd.value);
- if (sysctl(adjnumclusters, MIBSIZE, 0, 0,
+ if (bkgrdsumadj == 0 || sysctl(adjnumclusters, MIBSIZE, 0, 0,
&cmd, sizeof cmd) == -1)
rwerror("ADJUST NUMBER OF FREE CLUSTERS", cmd.value);
}
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index e95a6ad..f6b736d 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -140,6 +140,24 @@ setup(char *dev)
pfatal("kernel lacks background fsck support\n");
exit(EEXIT);
}
+ /*
+ * When kernel is lack of runtime bgfsck superblock summary
+ * adjustment functionality, it does not mean we can not
+ * continue, as old kernels will recompute the summary at
+ * mount time. However, it will be an unexpected softupdates
+ * inconsistency if it turns out that the summary is still
+ * incorrect. Set a flag so subsequent operation can know
+ * this.
+ */
+ bkgrdsumadj = 1;
+ if (sysctlnametomib("vfs.ffs.adjndir", adjndir, &size) < 0 ||
+ sysctlnametomib("vfs.ffs.adjnbfree", adjnbfree, &size) < 0 ||
+ sysctlnametomib("vfs.ffs.adjnifree", adjnifree, &size) < 0 ||
+ sysctlnametomib("vfs.ffs.adjnffree", adjnffree, &size) < 0 ||
+ sysctlnametomib("vfs.ffs.adjnumclusters", adjnumclusters, &size) < 0) {
+ bkgrdsumadj = 0;
+ pwarn("kernel lacks runtime superblock summary adjustment support");
+ }
cmd.version = FFS_CMD_VERSION;
cmd.handle = fsreadfd;
fswritefd = -1;
OpenPOWER on IntegriCloud