summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/setup.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2013-03-22 21:50:43 +0000
committermckusick <mckusick@FreeBSD.org>2013-03-22 21:50:43 +0000
commit93fa1464f28c355009625fdcfd4007c798c20d44 (patch)
treed0ed2db47b0d4e99dc2acac864e90741fd40ba47 /sbin/fsck_ffs/setup.c
parent45f62f67d30e33d8fa4d0e6d3a3a0ff5a231f18f (diff)
downloadFreeBSD-src-93fa1464f28c355009625fdcfd4007c798c20d44.zip
FreeBSD-src-93fa1464f28c355009625fdcfd4007c798c20d44.tar.gz
Speed up fsck by caching the cylinder group maps in pass1 so
that they do not need to be read again in pass5. As this nearly doubles the memory requirement for fsck, the cache is thrown away if other memory needs in fsck would otherwise fail. Thus, the memory footprint of fsck remains unchanged in memory constrained environments. This work was inspired by a paper presented at Usenix's FAST '13: www.usenix.org/conference/fast13/ffsck-fast-file-system-checker Details of this implementation appears in the April 2013 of ;login: www.usenix.org/publications/login/april-2013-volume-38-number-2. A copy of the April 2013 ;login: paper can also be downloaded from: www.mckusick.com/publications/faster_fsck.pdf. Reviewed by: kib Tested by: Peter Holm MFC after: 4 weeks
Diffstat (limited to 'sbin/fsck_ffs/setup.c')
-rw-r--r--sbin/fsck_ffs/setup.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index 32abeed..85e9548 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -240,7 +240,7 @@ setup(char *dev)
* read in the summary info.
*/
asked = 0;
- sblock.fs_csp = calloc(1, sblock.fs_cssize);
+ sblock.fs_csp = Calloc(1, sblock.fs_cssize);
if (sblock.fs_csp == NULL) {
printf("cannot alloc %u bytes for cg summary info\n",
(unsigned)sblock.fs_cssize);
@@ -265,13 +265,13 @@ setup(char *dev)
* allocate and initialize the necessary maps
*/
bmapsize = roundup(howmany(maxfsblock, CHAR_BIT), sizeof(short));
- blockmap = calloc((unsigned)bmapsize, sizeof (char));
+ blockmap = Calloc((unsigned)bmapsize, sizeof (char));
if (blockmap == NULL) {
printf("cannot alloc %u bytes for blockmap\n",
(unsigned)bmapsize);
goto badsb;
}
- inostathead = calloc((unsigned)(sblock.fs_ncg),
+ inostathead = Calloc((unsigned)(sblock.fs_ncg),
sizeof(struct inostatlist));
if (inostathead == NULL) {
printf("cannot alloc %u bytes for inostathead\n",
@@ -282,9 +282,9 @@ setup(char *dev)
dirhash = numdirs;
inplast = 0;
listmax = numdirs + 10;
- inpsort = (struct inoinfo **)calloc((unsigned)listmax,
+ inpsort = (struct inoinfo **)Calloc((unsigned)listmax,
sizeof(struct inoinfo *));
- inphead = (struct inoinfo **)calloc((unsigned)numdirs,
+ inphead = (struct inoinfo **)Calloc((unsigned)numdirs,
sizeof(struct inoinfo *));
if (inpsort == NULL || inphead == NULL) {
printf("cannot alloc %ju bytes for inphead\n",
@@ -444,8 +444,8 @@ sblock_init(void)
lfdir = 0;
initbarea(&sblk, BT_SUPERBLK);
initbarea(&asblk, BT_SUPERBLK);
- sblk.b_un.b_buf = malloc(SBLOCKSIZE);
- asblk.b_un.b_buf = malloc(SBLOCKSIZE);
+ sblk.b_un.b_buf = Malloc(SBLOCKSIZE);
+ asblk.b_un.b_buf = Malloc(SBLOCKSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
if ((lp = getdisklabel(NULL, fsreadfd)))
OpenPOWER on IntegriCloud