From 08983aee403bc92d4beda23a12cbbacb1f353363 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Tue, 18 May 2004 19:51:41 +0000 Subject: [PATCH] Improve the delay algorithm used in bgfsck. From the author: shuffles the timing and sleep calls in bgfsck from: sleep timer_on io timer_off io io io io io io io to sleep io io io io io io io timer_on io timer_off The original method basically guaranteed that the timed I/O included a disk seek every time, which made bgfsck sleep for much longer than necessary. Submitted by: Dan Nelson Reviewed by: kirk --- sbin/fsck_ffs/fsutil.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index 528e115e9eaa..28d539980795 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -478,10 +478,9 @@ void slowio_start() { - /* Delay one in every 8 operations by 16 times the average IO delay */ + /* Delay one in every 8 operations */ slowio_pollcnt = (slowio_pollcnt + 1) & 7; if (slowio_pollcnt == 0) { - usleep(slowio_delay_usec * 16); gettimeofday(&slowio_starttime, NULL); } } @@ -501,9 +500,12 @@ slowio_end() (tv.tv_usec - slowio_starttime.tv_usec); if (delay_usec < 64) delay_usec = 64; - if (delay_usec > 1000000) - delay_usec = 1000000; + if (delay_usec > 2500000) + delay_usec = 2500000; slowio_delay_usec = (slowio_delay_usec * 63 + delay_usec) >> 6; + /* delay by 8 times the average IO delay */ + if (slowio_delay_usec > 64) + usleep(slowio_delay_usec * 8); } /*