From 03237de00aa4fc0ac5910524c00aaef3db369e0d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 14 Sep 2012 00:11:07 -0400 Subject: [PATCH] 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" --- misc/mke2fs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 7ec8cc2..4250335 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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; -- 1.8.3.1