2000-02-08 <tytso@snap.thunk.org>
+ * e2fsck.h:
+ * pass1.c (mark_table_blocks, e2fsck_pass1): Remove
+ ctx->block_illegal_map, since it's not needed by pass1,
+ and pass1b has been modified to calculate it manually if
+ needed. This reduces the memory footprint needed by e2fsck.
+
+ * pass1b.c (check_if_fs_block): New static function which returns
+ whether or not a block overlaps with filesystem metadata.
+ This replaces consulting the block_illegal_map bitmap.
+
* Makefile.in: Call sync after finishing building all in this
directory.
ext2fs_block_bitmap block_found_map; /* Blocks which are in use */
ext2fs_block_bitmap block_dup_map; /* Blks referenced more than once */
- ext2fs_block_bitmap block_illegal_map; /* Meta-data blocks */
/*
* Inode count arrays
ctx->flags |= E2F_FLAG_ABORT;
return;
}
- pctx.errcode = ext2fs_allocate_block_bitmap(fs, _("illegal block map"),
- &ctx->block_illegal_map);
- if (pctx.errcode) {
- pctx.num = 2;
- fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx);
- ctx->flags |= E2F_FLAG_ABORT;
- return;
- }
pctx.errcode = ext2fs_create_icount2(fs, 0, 0, 0,
&ctx->inode_link_info);
if (pctx.errcode) {
e2fsck_use_inode_shortcuts(ctx, 0);
ext2fs_free_mem((void **) &block_buf);
- ext2fs_free_block_bitmap(ctx->block_illegal_map);
- ctx->block_illegal_map = 0;
if (ctx->large_files &&
!(sb->s_feature_ro_compat &
if (blk < fs->super->s_first_data_block ||
blk >= fs->super->s_blocks_count)
problem = PR_1_ILLEGAL_BLOCK_NUM;
-#if 0
- else
- if (ext2fs_test_block_bitmap(block_illegal_map, blk))
- problem = PR_1_BLOCK_OVERLAPS_METADATA;
-#endif
if (problem) {
p->num_illegal_blocks++;
* Mark this group's copy of the superblock
*/
ext2fs_mark_block_bitmap(ctx->block_found_map, block);
- ext2fs_mark_block_bitmap(ctx->block_illegal_map,
- block);
/*
* Mark this group's copy of the descriptors
for (j = 0; j < fs->desc_blocks; j++) {
ext2fs_mark_block_bitmap(ctx->block_found_map,
block + j + 1);
- ext2fs_mark_block_bitmap(ctx->block_illegal_map,
- block + j + 1);
}
}
} else {
ext2fs_mark_block_bitmap(ctx->block_found_map,
b);
- ext2fs_mark_block_bitmap(ctx->block_illegal_map,
- b);
}
}
}
} else {
ext2fs_mark_block_bitmap(ctx->block_found_map,
fs->group_desc[i].bg_block_bitmap);
- ext2fs_mark_block_bitmap(ctx->block_illegal_map,
- fs->group_desc[i].bg_block_bitmap);
}
}
} else {
ext2fs_mark_block_bitmap(ctx->block_found_map,
fs->group_desc[i].bg_inode_bitmap);
- ext2fs_mark_block_bitmap(ctx->block_illegal_map,
- fs->group_desc[i].bg_inode_bitmap);
}
}
block += fs->super->s_blocks_per_group;
static void delete_file(e2fsck_t ctx, struct dup_inode *dp,
char *block_buf);
static int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf);
+static int check_if_fs_block(e2fsck_t ctx, blk_t test_blk);
+
static void pass1b(e2fsck_t ctx, char *block_buf);
static void pass1c(e2fsck_t ctx, char *block_buf);
static void pass1d(e2fsck_t ctx, char *block_buf);
continue;
if (q->num_bad > 1)
file_ok = 0;
- if (ext2fs_test_block_bitmap(ctx->block_illegal_map,
- q->block)) {
+ if (check_if_fs_block(ctx, q->block)) {
file_ok = 0;
meta_data = 1;
}
}
p->num_bad--;
if (p->num_bad == 1 &&
- !ext2fs_test_block_bitmap(ctx->block_illegal_map,
- *block_nr))
+ !check_if_fs_block(ctx, *block_nr))
ext2fs_unmark_block_bitmap(ctx->block_dup_map,
*block_nr);
*block_nr = new_block;
}
return 0;
}
+
+/*
+ * This routine returns 1 if a block overlaps with one of the superblocks,
+ * group descriptors, inode bitmaps, or block bitmaps.
+ */
+static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
+{
+ ext2_filsys fs = ctx->fs;
+ blk_t block;
+ int i;
+
+ block = fs->super->s_first_data_block;
+ for (i = 0; i < fs->group_desc_count; i++) {
+
+ /* Check superblocks/block group descriptros */
+ if (ext2fs_bg_has_super(fs, i)) {
+ if (test_block >= block &&
+ (test_block <= block + fs->desc_blocks))
+ return 1;
+ }
+
+ /* Check the inode table */
+ if ((fs->group_desc[i].bg_inode_table) &&
+ (test_block >= fs->group_desc[i].bg_inode_table) &&
+ (test_block < (fs->group_desc[i].bg_inode_table +
+ fs->inode_blocks_per_group)))
+ return 1;
+
+ /* Check the bitmap blocks */
+ if ((test_block == fs->group_desc[i].bg_block_bitmap) ||
+ (test_block == fs->group_desc[i].bg_inode_bitmap))
+ return 1;
+
+ block += fs->super->s_blocks_per_group;
+ }
+ return 0;
+}
printf("%s: ", desc);
#ifdef HAVE_MALLINFO
+#define kbytes(x) (((x) + 1023) / 1024)
+
malloc_info = mallinfo();
- printf(_("Memory used: %d/%d, "),
- malloc_info.arena, malloc_info.hblkhd);
+ printf(_("Memory used: %dk/%dk (%dk/%dk), "),
+ kbytes(malloc_info.arena), kbytes(malloc_info.hblkhd),
+ kbytes(malloc_info.uordblks), kbytes(malloc_info.fordblks));
#else
printf(_("Memory used: %d, "),
(int) (((char *) sbrk(0)) - ((char *) track->brk_start)));
#ifdef HAVE_GETRUSAGE
getrusage(RUSAGE_SELF, &r);
- printf(_("elapsed time: %6.3f/%6.3f/%6.3f\n"),
+ printf(_("time: %5.2f/%5.2f/%5.2f\n"),
timeval_subtract(&time_end, &track->time_start),
timeval_subtract(&r.ru_utime, &track->user_start),
timeval_subtract(&r.ru_stime, &track->system_start));