Sun Oct 19 21:12:11 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
+ * 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
PROGS= e2fsck @EXTRA_PROGS@
MANPAGES= e2fsck.8
+XTRA_CFLAGS= -DRESOURCE_TRACK
LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBUUID)
DEPLIBS= $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBUUID)
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.
struct timeval system_start;
void *brk_start;
};
+#endif
/*
* E2fsck options
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;
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);
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))
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
}
/*
{
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);
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
}
/*
{
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);
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);
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
}
/*
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");
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
}
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);
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)
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");
EXT2_FLAG_SWAP_BYTES_WRITE);
ext2fs_flush(fs);
+#ifdef RESOURCE_TRACK
if (ctx->options & E2F_OPT_TIME2)
print_resource_track("Byte swap", &rtrack);
+#endif
}
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++;
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",
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);
exit(FSCK_UNCORRECTED);
}
+#ifdef RESOURCE_TRACK
void init_resource_track(struct resource_track *track)
{
#ifdef HAVE_GETRUSAGE
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)