diff options
author | mckusick <mckusick@FreeBSD.org> | 2013-03-22 21:50:43 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2013-03-22 21:50:43 +0000 |
commit | 93fa1464f28c355009625fdcfd4007c798c20d44 (patch) | |
tree | d0ed2db47b0d4e99dc2acac864e90741fd40ba47 /sbin/fsck_ffs/fsck.h | |
parent | 45f62f67d30e33d8fa4d0e6d3a3a0ff5a231f18f (diff) | |
download | FreeBSD-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/fsck.h')
-rw-r--r-- | sbin/fsck_ffs/fsck.h | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index ef98fa2..7b45d48 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -198,7 +198,6 @@ struct timespec totalreadtime[BT_NUMBUFTYPES]; struct timespec startprog; struct bufarea sblk; /* file system superblock */ -struct bufarea cgblk; /* cylinder group blocks */ struct bufarea *pdirbp; /* current directory contents */ struct bufarea *pbp; /* current inode block */ @@ -216,9 +215,7 @@ struct bufarea *pbp; /* current inode block */ } while (0) #define sbdirty() dirty(&sblk) -#define cgdirty() dirty(&cgblk) #define sblock (*sblk.b_un.b_fs) -#define cgrp (*cgblk.b_un.b_cg) enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE}; ino_t cursnapshot; @@ -361,6 +358,37 @@ struct ufs2_dinode ufs2_zino; #define EEXIT 8 /* Standard error exit. */ +int flushentry(void); +/* + * Wrapper for malloc() that flushes the cylinder group cache to try + * to get space. + */ +static inline void* +Malloc(int size) +{ + void *retval; + + while ((retval = malloc(size)) == NULL) + if (flushentry() == 0) + break; + return (retval); +} + +/* + * Wrapper for calloc() that flushes the cylinder group cache to try + * to get space. + */ +static inline void* +Calloc(int cnt, int size) +{ + void *retval; + + while ((retval = calloc(cnt, size)) == NULL) + if (flushentry() == 0) + break; + return (retval); +} + struct fstab; @@ -378,7 +406,7 @@ void cacheino(union dinode *dp, ino_t inumber); void catch(int); void catchquit(int); int changeino(ino_t dir, const char *name, ino_t newnum); -int check_cgmagic(int cg, struct cg *cgp); +int check_cgmagic(int cg, struct bufarea *cgbp); int chkrange(ufs2_daddr_t blk, int cnt); void ckfini(int markclean); int ckinode(union dinode *dp, struct inodesc *); @@ -398,6 +426,7 @@ void freeino(ino_t ino); void freeinodebuf(void); int ftypeok(union dinode *dp); void getblk(struct bufarea *bp, ufs2_daddr_t blk, long size); +struct bufarea *cgget(int cg); struct bufarea *getdatablk(ufs2_daddr_t blkno, long size, int type); struct inoinfo *getinoinfo(ino_t inumber); union dinode *getnextinode(ino_t inumber, int rebuildcg); |