mke2fs: throttle progress updates to once a second

With lazy itable initialization, the progress updates for writing the
inode table happens so quickly that on a serial console, the time to
write the progress updates can be the bottleneck.  Fix this by only
updating the progress indicator once a second.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2012-09-14 00:11:07 -04:00
parent 2d8c0c8a4f
commit 03237de00a
1 changed files with 12 additions and 2 deletions

View File

@ -309,6 +309,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
errcode_t retval;
blk64_t blk;
dgrp_t i;
time_t now, last_update = 0;
int num;
struct ext2fs_numeric_progress_struct progress;
@ -317,7 +318,11 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
fs->group_desc_count);
for (i = 0; i < fs->group_desc_count; i++) {
ext2fs_numeric_progress_update(fs, &progress, i);
now = time(0);
if (now != last_update) {
ext2fs_numeric_progress_update(fs, &progress, i);
last_update = now;
}
blk = ext2fs_inode_table_loc(fs, i);
num = fs->inode_blocks_per_group;
@ -2136,6 +2141,7 @@ static int mke2fs_discard_device(ext2_filsys fs)
blk64_t count = DISCARD_STEP_MB;
blk64_t cur;
int retval = 0;
time_t now, last_update = 0;
/*
* Let's try if discard really works on the device, so
@ -2154,7 +2160,11 @@ static int mke2fs_discard_device(ext2_filsys fs)
_("Discarding device blocks: "),
blocks);
while (cur < blocks) {
ext2fs_numeric_progress_update(fs, &progress, cur);
now = time(0);
if (now != last_update) {
ext2fs_numeric_progress_update(fs, &progress, cur);
last_update = now;
}
if (cur + count > blocks)
count = blocks - cur;