mirror of https://github.com/vitalif/e2fsprogs
mke2fs: Use ext2fs_flush() only once
We are doing ext2fs_flush() twice right now at the end of the mke2fs. First by directly calling ext2fs_flush() which is intended to write superblock and fs accounting information. And then it is invoked again when we are calling ext2fs_close(), only this time, because the fs is not dirty, we are writing out only superblock. I think it is bad to call it twice because even when writing only super block it takes some time on bigger file systems and moreover ext2fs_close() can fail without any reasonable explanation for the user. Also ext2fs_flush() is printing out progress and it is confusing for the users. Fix all this by removing the ext2fs_flush() and leaving it all to ext2fs_close(). However we need to introduce new variables to store check interval and max mount count, because fs structure is freed on ext2fs_close() and we really want to print those information as the last info for the user. [ Fixed type mismatch in a printf format statement -tytso] Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>bitmap-optimize
parent
906a1cf9b6
commit
faa2dcdad0
|
@ -2158,7 +2158,7 @@ int main (int argc, char *argv[])
|
||||||
ext2_filsys fs;
|
ext2_filsys fs;
|
||||||
badblocks_list bb_list = 0;
|
badblocks_list bb_list = 0;
|
||||||
unsigned int journal_blocks;
|
unsigned int journal_blocks;
|
||||||
unsigned int i;
|
unsigned int i, max_mnt_count, checkinterval;
|
||||||
int val, hash_alg;
|
int val, hash_alg;
|
||||||
int flags;
|
int flags;
|
||||||
int old_bitmaps;
|
int old_bitmaps;
|
||||||
|
@ -2488,22 +2488,23 @@ no_journal:
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
printf(_("Writing superblocks and "
|
printf(_("Writing superblocks and "
|
||||||
"filesystem accounting information: "));
|
"filesystem accounting information: "));
|
||||||
retval = ext2fs_flush(fs);
|
checkinterval = fs->super->s_checkinterval;
|
||||||
|
max_mnt_count = fs->super->s_max_mnt_count;
|
||||||
|
retval = ext2fs_close(fs);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
_("\nWarning, had trouble writing out superblocks."));
|
_("\nWarning, had trouble writing out superblocks."));
|
||||||
}
|
} else if (!quiet) {
|
||||||
if (!quiet) {
|
|
||||||
printf(_("done\n\n"));
|
printf(_("done\n\n"));
|
||||||
if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
|
if (!getenv("MKE2FS_SKIP_CHECK_MSG"))
|
||||||
print_check_message(fs);
|
print_check_message(max_mnt_count, checkinterval);
|
||||||
}
|
}
|
||||||
val = ext2fs_close(fs);
|
|
||||||
remove_error_table(&et_ext2_error_table);
|
remove_error_table(&et_ext2_error_table);
|
||||||
remove_error_table(&et_prof_error_table);
|
remove_error_table(&et_prof_error_table);
|
||||||
profile_release(profile);
|
profile_release(profile);
|
||||||
for (i=0; fs_types[i]; i++)
|
for (i=0; fs_types[i]; i++)
|
||||||
free(fs_types[i]);
|
free(fs_types[i]);
|
||||||
free(fs_types);
|
free(fs_types);
|
||||||
return (retval || val) ? 1 : 0;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,7 +607,8 @@ static void add_journal(ext2_filsys fs)
|
||||||
if ((mount_flags & EXT2_MF_MOUNTED) == 0)
|
if ((mount_flags & EXT2_MF_MOUNTED) == 0)
|
||||||
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
|
||||||
}
|
}
|
||||||
print_check_message(fs);
|
print_check_message(fs->super->s_max_mnt_count,
|
||||||
|
fs->super->s_checkinterval);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
|
|
@ -282,12 +282,11 @@ unsigned int figure_journal_size(int size, ext2_filsys fs)
|
||||||
return j_blocks;
|
return j_blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_check_message(ext2_filsys fs)
|
void print_check_message(unsigned int mnt, unsigned int check)
|
||||||
{
|
{
|
||||||
printf(_("This filesystem will be automatically "
|
printf(_("This filesystem will be automatically "
|
||||||
"checked every %d mounts or\n"
|
"checked every %d mounts or\n"
|
||||||
"%g days, whichever comes first. "
|
"%g days, whichever comes first. "
|
||||||
"Use tune2fs -c or -i to override.\n"),
|
"Use tune2fs -c or -i to override.\n"),
|
||||||
fs->super->s_max_mnt_count,
|
mnt, ((double) check) / (3600 * 24));
|
||||||
(double)fs->super->s_checkinterval / (3600 * 24));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,4 +23,4 @@ extern void check_plausibility(const char *device);
|
||||||
extern void parse_journal_opts(const char *opts);
|
extern void parse_journal_opts(const char *opts);
|
||||||
extern void check_mount(const char *device, int force, const char *type);
|
extern void check_mount(const char *device, int force, const char *type);
|
||||||
extern unsigned int figure_journal_size(int size, ext2_filsys fs);
|
extern unsigned int figure_journal_size(int size, ext2_filsys fs);
|
||||||
extern void print_check_message(ext2_filsys fs);
|
extern void print_check_message(unsigned int, unsigned int);
|
||||||
|
|
|
@ -18,7 +18,7 @@ Writing inode tables: 0/81/82/83/84/85/86/87/8 done
|
||||||
Creating journal (4096 blocks): done
|
Creating journal (4096 blocks): done
|
||||||
Writing superblocks and filesystem accounting information: 0/81/82/83/84/85/86/87/8 done
|
Writing superblocks and filesystem accounting information: 0/81/82/83/84/85/86/87/8 done
|
||||||
|
|
||||||
0/81/82/83/84/85/86/87/8 Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent sparse_super
|
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent sparse_super
|
||||||
|
|
||||||
Pass 1: Checking inodes, blocks, and sizes
|
Pass 1: Checking inodes, blocks, and sizes
|
||||||
Pass 2: Checking directory structure
|
Pass 2: Checking directory structure
|
||||||
|
|
|
@ -17,7 +17,7 @@ Allocating group tables: 0/16 1/16 2/16 3/16 4/16 5/16
|
||||||
Writing inode tables: 0/16 1/16 2/16 3/16 4/16 5/16 6/16 7/16 8/16 9/1610/1611/1612/1613/1614/1615/16 done
|
Writing inode tables: 0/16 1/16 2/16 3/16 4/16 5/16 6/16 7/16 8/16 9/1610/1611/1612/1613/1614/1615/16 done
|
||||||
Writing superblocks and filesystem accounting information: 0/16 1/16 2/16 3/16 4/16 5/16 6/16 7/16 8/16 9/1610/1611/1612/1613/1614/1615/16 done
|
Writing superblocks and filesystem accounting information: 0/16 1/16 2/16 3/16 4/16 5/16 6/16 7/16 8/16 9/1610/1611/1612/1613/1614/1615/16 done
|
||||||
|
|
||||||
0/16 1/16 2/16 3/16 4/16 5/16 6/16 7/16 8/16 9/1610/1611/1612/1613/1614/1615/16 Filesystem features: ext_attr resize_inode dir_index filetype sparse_super uninit_bg
|
Filesystem features: ext_attr resize_inode dir_index filetype sparse_super uninit_bg
|
||||||
|
|
||||||
Pass 1: Checking inodes, blocks, and sizes
|
Pass 1: Checking inodes, blocks, and sizes
|
||||||
Pass 2: Checking directory structure
|
Pass 2: Checking directory structure
|
||||||
|
|
Loading…
Reference in New Issue