diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-04-22 23:18:37 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-04-22 23:18:37 -0400 |
commit | 0f2794c020b34de391f7a42e3b155ccb0ed2830f (patch) | |
tree | aa95527eda1f4a2c854368f5dc541ba7dac852ed /misc/mke2fs.c | |
parent | 4476105bf377eb9bd30d2771b21b2ada06c13e82 (diff) | |
download | e2fsprogs-0f2794c020b34de391f7a42e3b155ccb0ed2830f.tar.gz |
mke2fs/libext2fs: Fix lazy inode table initialization
This fixes some bugs which I introduced recently while revamping the
uninit_bg code. Since mke2fs is no longer calling
ext2fs_set_gdt_csum(), it's important that ext2fs_initialize()
correctly initialize bg_itable_unused for all block group descriptors.
In addition, mke2fs needs to zero out the the reserved inodes based on
the values of bg_itable_unused set by ext2fs_initialize().
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'misc/mke2fs.c')
-rw-r--r-- | misc/mke2fs.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 61f45aa6..11dffb70 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -406,7 +406,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag) errcode_t retval; blk_t blk; dgrp_t i; - int num; + int num, ipb; struct progress_struct progress; if (quiet) @@ -421,19 +421,28 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag) blk = fs->group_desc[i].bg_inode_table; num = fs->inode_blocks_per_group; - if (!(lazy_flag && - (fs->group_desc[i].bg_flags & EXT2_BG_INODE_UNINIT))) { - retval = zero_blocks(fs, blk, num, 0, &blk, &num); - if (retval) { - fprintf(stderr, _("\nCould not write %d " - "blocks in inode table starting at %u: %s\n"), - num, blk, error_message(retval)); - exit(1); - } + if (lazy_flag) { + ipb = fs->blocksize / EXT2_INODE_SIZE(fs->super); + printf("bg %i, num %d, ipb %d, unused %d ", + i, num, ipb, fs->group_desc[i].bg_itable_unused); + num = ((((fs->super->s_inodes_per_group - + fs->group_desc[i].bg_itable_unused) * + EXT2_INODE_SIZE(fs->super)) + + EXT2_BLOCK_SIZE(fs->super) - 1) / + EXT2_BLOCK_SIZE(fs->super)); + printf("new num %d\n", num); + } else { /* The kernel doesn't need to zero the itable blocks */ fs->group_desc[i].bg_flags |= EXT2_BG_INODE_ZEROED; ext2fs_group_desc_csum_set(fs, i); } + retval = zero_blocks(fs, blk, num, 0, &blk, &num); + if (retval) { + fprintf(stderr, _("\nCould not write %d " + "blocks in inode table starting at %u: %s\n"), + num, blk, error_message(retval)); + exit(1); + } if (sync_kludge) { if (sync_kludge == 1) sync(); |