Whamcloud - gitweb
mke2fs: throttle progress updates to once a second
authorTheodore Ts'o <tytso@mit.edu>
Fri, 14 Sep 2012 04:11:07 +0000 (00:11 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 14 Sep 2012 04:11:07 +0000 (00:11 -0400)
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>
misc/mke2fs.c

index 7ec8cc2..4250335 100644 (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;