diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index d8de07f8..880975f4 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,5 +1,9 @@ Sun Oct 19 21:12:11 1997 Theodore Ts'o + * pass*.c, super.c, unix.c, util.c, e2fsck.h: Place #ifdef + RESOURCE_TRACK around code which uses init_resource_track + and print_resource_track. (Not all systems have timeval) + * super.c: Remove excess #includes which are not necessary. * e2fsck.h: Add #ifdef's for HAVE_SYS_TYPES_H and HAVE_SYS_TIME_H diff --git a/e2fsck/Makefile.in b/e2fsck/Makefile.in index afb130bf..40595e61 100644 --- a/e2fsck/Makefile.in +++ b/e2fsck/Makefile.in @@ -14,6 +14,7 @@ LDFLAG_STATIC = @LDFLAG_STATIC@ PROGS= e2fsck @EXTRA_PROGS@ MANPAGES= e2fsck.8 +XTRA_CFLAGS= -DRESOURCE_TRACK LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBUUID) DEPLIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBUUID) diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index b185d6bb..83c5d610 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -59,6 +59,7 @@ struct dir_info { ino_t parent; /* Parent according to treewalk */ }; +#ifdef RESOURCE_TRACK /* * This structure is used for keeping track of how much resources have * been used for a particular pass of e2fsck. @@ -69,6 +70,7 @@ struct resource_track { struct timeval system_start; void *brk_start; }; +#endif /* * E2fsck options @@ -130,10 +132,12 @@ struct e2fsck_struct { int process_inode_size; int inode_buffer_blocks; +#ifdef RESOURCE_TRACK /* * For timing purposes */ struct resource_track global_rtrack; +#endif /* File counts */ int fs_directory_count; @@ -215,9 +219,11 @@ extern void fatal_error (const char * fmt_string); extern void read_bitmaps(e2fsck_t ctx); extern void write_bitmaps(e2fsck_t ctx); extern void preenhalt(e2fsck_t ctx); +#ifdef RESOURCE_TRACK extern void print_resource_track(const char *desc, struct resource_track *track); extern void init_resource_track(struct resource_track *track); +#endif extern int inode_has_valid_blocks(struct ext2_inode *inode); extern void e2fsck_read_inode(ext2_filsys fs, unsigned long ino, struct ext2_inode * inode, const char * proc); diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index bd046d21..bda1a515 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -120,11 +120,15 @@ void pass1(e2fsck_t ctx) struct ext2_inode inode; ext2_inode_scan scan; char *block_buf; +#ifdef RESOURCE_TRACK struct resource_track rtrack; +#endif unsigned char frag, fsize; struct problem_context pctx; +#ifdef RESOURCE_TRACK init_resource_track(&rtrack); +#endif clear_problem_context(&pctx); if (!(ctx->options & E2F_OPT_PREEN)) @@ -435,8 +439,10 @@ endit: ext2fs_free_block_bitmap(ctx->block_illegal_map); ctx->block_illegal_map = 0; +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME2) print_resource_track("Pass 1", &rtrack); +#endif } /* diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index bcd8aa2f..edb24821 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -70,11 +70,15 @@ void pass2(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; char *buf; +#ifdef RESOURCE_TRACK struct resource_track rtrack; +#endif struct dir_info *dir; struct check_dir_struct cd; +#ifdef RESOURCE_TRACK init_resource_track(&rtrack); +#endif clear_problem_context(&cd.pctx); @@ -120,8 +124,10 @@ void pass2(e2fsck_t ctx) ext2fs_free_inode_bitmap(ctx->inode_bad_map); ctx->inode_bad_map = 0; } +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME2) print_resource_track("Pass 2", &rtrack); +#endif } /* diff --git a/e2fsck/pass3.c b/e2fsck/pass3.c index 7d7c6495..52c19c91 100644 --- a/e2fsck/pass3.c +++ b/e2fsck/pass3.c @@ -59,11 +59,15 @@ void pass3(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; int i; +#ifdef RESOURCE_TRACK struct resource_track rtrack; +#endif struct problem_context pctx; struct dir_info *dir; +#ifdef RESOURCE_TRACK init_resource_track(&rtrack); +#endif clear_problem_context(&pctx); @@ -91,8 +95,10 @@ void pass3(e2fsck_t ctx) fix_problem(ctx, PR_3_ALLOCATE_IBITMAP_ERROR, &pctx); fatal_error(0); } +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME) print_resource_track("Peak memory", &ctx->global_rtrack); +#endif check_root(ctx); ext2fs_mark_inode_bitmap(inode_done_map, EXT2_ROOT_INO); @@ -106,8 +112,10 @@ void pass3(e2fsck_t ctx) free_dir_info(fs); ext2fs_free_inode_bitmap(inode_loop_detect); ext2fs_free_inode_bitmap(inode_done_map); +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME2) print_resource_track("Pass 3", &rtrack); +#endif } /* diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c index f5784cfd..9b814b4a 100644 --- a/e2fsck/pass4.c +++ b/e2fsck/pass4.c @@ -80,11 +80,15 @@ void pass4(e2fsck_t ctx) ext2_filsys fs = ctx->fs; ino_t i; struct ext2_inode inode; +#ifdef RESOURCE_TRACK struct resource_track rtrack; +#endif struct problem_context pctx; __u16 link_count, link_counted; +#ifdef RESOURCE_TRACK init_resource_track(&rtrack); +#endif #ifdef MTRACE mtrace_print("Pass 4"); @@ -133,7 +137,9 @@ void pass4(e2fsck_t ctx) ext2fs_free_icount(ctx->inode_count); ctx->inode_count = 0; ext2fs_free_inode_bitmap(ctx->inode_bb_map); ctx->inode_bb_map = 0; +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME2) print_resource_track("Pass 4", &rtrack); +#endif } diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c index 499c92ce..be2edd9a 100644 --- a/e2fsck/pass5.c +++ b/e2fsck/pass5.c @@ -20,14 +20,18 @@ static void check_block_end(e2fsck_t ctx); void pass5(e2fsck_t ctx) { +#ifdef RESOURCE_TRACK struct resource_track rtrack; +#endif struct problem_context pctx; #ifdef MTRACE mtrace_print("Pass 5"); #endif +#ifdef RESOURCE_TRACK init_resource_track(&rtrack); +#endif clear_problem_context(&pctx); @@ -48,8 +52,10 @@ void pass5(e2fsck_t ctx) ext2fs_free_block_bitmap(ctx->block_found_map); ctx->block_found_map = 0; +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME2) print_resource_track("Pass 5", &rtrack); +#endif } static void check_block_bitmaps(e2fsck_t ctx) diff --git a/e2fsck/swapfs.c b/e2fsck/swapfs.c index 64d4775a..f6d3d702 100644 --- a/e2fsck/swapfs.c +++ b/e2fsck/swapfs.c @@ -177,9 +177,11 @@ static void swap_inodes(e2fsck_t ctx) void swap_filesys(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; +#ifdef RESOURCE_TRACK struct resource_track rtrack; init_resource_track(&rtrack); +#endif if (!(ctx->options & E2F_OPT_PREEN)) printf("Pass 0: Doing byte-swap of filesystem\n"); @@ -210,8 +212,10 @@ void swap_filesys(e2fsck_t ctx) EXT2_FLAG_SWAP_BYTES_WRITE); ext2fs_flush(fs); +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME2) print_resource_track("Byte swap", &rtrack); +#endif } diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 7bc0963c..11256708 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -288,10 +288,15 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) ctx->options &= ~(E2F_OPT_PREEN|E2F_OPT_NO); break; case 't': +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME) ctx->options |= E2F_OPT_TIME2; else ctx->options |= E2F_OPT_TIME; +#else + fprintf(stderr, "The -t option is not " + "supported on this version of e2fsck.\n"); +#endif break; case 'c': cflag++; @@ -433,7 +438,9 @@ int main (int argc, char *argv[]) exit(1); } +#ifdef RESOURCE_TRACK init_resource_track(&ctx->global_rtrack); +#endif if (!(ctx->options & E2F_OPT_PREEN) || show_version_only) fprintf (stderr, "e2fsck %s, %s for EXT2 FS %s, %s\n", @@ -642,8 +649,10 @@ restart: ext2fs_close(fs); sync_disks(); +#ifdef RESOURCE_TRACK if (ctx->options & E2F_OPT_TIME) print_resource_track(NULL, &ctx->global_rtrack); +#endif e2fsck_free_context(ctx); diff --git a/e2fsck/util.c b/e2fsck/util.c index 879e7baa..f676b263 100644 --- a/e2fsck/util.c +++ b/e2fsck/util.c @@ -175,6 +175,7 @@ void preenhalt(e2fsck_t ctx) exit(FSCK_UNCORRECTED); } +#ifdef RESOURCE_TRACK void init_resource_track(struct resource_track *track) { #ifdef HAVE_GETRUSAGE @@ -235,6 +236,7 @@ void print_resource_track(const char *desc, struct resource_track *track) timeval_subtract(&time_end, &track->time_start)); #endif } +#endif /* RESOURCE_TRACK */ void e2fsck_read_inode(ext2_filsys fs, unsigned long ino, struct ext2_inode * inode, const char *proc)