Whamcloud - gitweb
ChangeLog, e2fsck.h, pass1.c, pass1b.c:
authorTheodore Ts'o <tytso@mit.edu>
Tue, 8 Feb 2000 23:19:32 +0000 (23:19 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 8 Feb 2000 23:19:32 +0000 (23:19 +0000)
  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.
util.c:
  Make resource tracking message more concise.

e2fsck/ChangeLog
e2fsck/e2fsck.h
e2fsck/pass1.c
e2fsck/pass1b.c
e2fsck/util.c

index abc0253..5677622 100644 (file)
@@ -1,5 +1,15 @@
 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. 
        
index e4a6837..28f2a90 100644 (file)
@@ -166,7 +166,6 @@ struct e2fsck_struct {
 
        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
index 25dd09d..cf30ef6 100644 (file)
@@ -238,14 +238,6 @@ void e2fsck_pass1(e2fsck_t ctx)
                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) {
@@ -558,8 +550,6 @@ endit:
        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 & 
@@ -995,11 +985,6 @@ int process_block(ext2_filsys fs,
        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++;
@@ -1310,8 +1295,6 @@ static void mark_table_blocks(e2fsck_t ctx)
                         * 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
@@ -1319,8 +1302,6 @@ static void mark_table_blocks(e2fsck_t ctx)
                        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);
                        }
                }
                
@@ -1342,8 +1323,6 @@ static void mark_table_blocks(e2fsck_t ctx)
                                } else {
                                    ext2fs_mark_block_bitmap(ctx->block_found_map,
                                                             b);
-                                   ext2fs_mark_block_bitmap(ctx->block_illegal_map,
-                                                            b);
                                }
                        }
                }
@@ -1362,8 +1341,6 @@ static void mark_table_blocks(e2fsck_t ctx)
                        } 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);
                    }
                        
                }
@@ -1381,8 +1358,6 @@ static void mark_table_blocks(e2fsck_t ctx)
                        } 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;
index 03e3b72..a1cbf18 100644 (file)
@@ -92,6 +92,8 @@ static int process_pass1b_block(ext2_filsys fs, blk_t *blocknr,
 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);
@@ -408,8 +410,7 @@ 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;
                        }
@@ -602,8 +603,7 @@ static int clone_file_block(ext2_filsys fs,
                        }
                        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;
@@ -652,3 +652,40 @@ static int clone_file(e2fsck_t ctx, struct dup_inode *dp, char* block_buf)
        }
        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;
+}
index d525ba6..9fd0114 100644 (file)
@@ -251,9 +251,12 @@ void print_resource_track(const char *desc, struct resource_track *track)
                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)));
@@ -261,7 +264,7 @@ void print_resource_track(const char *desc, struct resource_track *track)
 #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));