
e2fsck on a serial console can take a _lot_ of time if the progress
indicator is turned on, as it is with recent sysvinit versions. This
is because of 2 reasons:

- The logic in e2fsck/unix.c that calculates how often to update the
  display is wrong by a factor 100. It seems like the author assumed
  that the 'percent' variable was between 0 and 1.
- Even with this fixed, still 1000 * 80 characters are output at least
  before the check is complete. Printing 8000 characters @ 9600 baud
  takes 66 seconds, so even if e2fsck could be done in 6 seconds it
  will still take 1 more minute just to print out the progress bar.

The following patch fixes both issues, the last one by simply not updating
the display more than 10 times a second which seems to work perfectly.

It cuts my fsck times down from 10 minutes to 30 seconds or so ...

--- e2fsprogs-1.18.orig/e2fsck/e2fsck.h
+++ e2fsprogs-1.18/e2fsck/e2fsck.h
@@ -202,6 +202,7 @@
 	int progress_fd;
 	int progress_pos;
 	int progress_last_percent;
+	long progress_last_time;
 
 	/* File counts */
 	int fs_directory_count;
--- e2fsprogs-1.18.orig/e2fsck/unix.c
+++ e2fsprogs-1.18/e2fsck/unix.c
@@ -32,6 +32,7 @@
 #endif
 #include <sys/ioctl.h>
 #include <malloc.h>
+#include <sys/param.h>
 
 #include "et/com_err.h"
 #include "e2fsck.h"
@@ -285,6 +286,7 @@
 	char buf[80];
 	int	i;
 	float percent;
+	long	now;
 
 	if (pass == 0)
 		return 0;
@@ -295,12 +297,16 @@
 	} else {
 		if (ctx->flags & E2F_FLAG_PROG_SUPPRESS)
 			return 0;
-		ctx->progress_pos = (ctx->progress_pos+1) & 3;
 		ctx->flags |= E2F_FLAG_PROG_BAR;
 		percent = calc_percent(&e2fsck_tbl, pass, cur, max);
-		if (ctx->progress_last_percent == (int) 1000 * percent)
+		if (ctx->progress_last_percent == (int) 10 * percent)
+			return 0;
+		now = (long)times(NULL);
+		if (now >= 0 && (now - ctx->progress_last_time < (HZ / 10)))
 			return 0;
-		ctx->progress_last_percent = (int) 1000 * percent;
+		ctx->progress_last_percent = (int) 10 * percent;
+		ctx->progress_last_time = now;
+		ctx->progress_pos = (ctx->progress_pos+1) & 3;
 		i = ((percent * dpywidth) + 50) / 100;
 		printf("%s: |%s%s", ctx->device_name,
 		       bar + (sizeof(bar) - (i+1)),
