From root@shell.dragondata.com  Tue Feb 17 00:10:11 1998
Received: from shell.dragondata.com (root@shell.dragondata.com [204.137.237.8])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id AAA01047
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 17 Feb 1998 00:10:09 -0800 (PST)
          (envelope-from root@shell.dragondata.com)
Received: (from root@localhost)
	by shell.dragondata.com (8.8.8/8.8.7) id CAA01127;
	Tue, 17 Feb 1998 02:10:09 -0600 (CST)
	(envelope-from root)
Message-Id: <199802170810.CAA01127@shell.dragondata.com>
Date: Tue, 17 Feb 1998 02:10:09 -0600 (CST)
From: toasty@dragondata.com
Reply-To: toasty@dragondata.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Shutdown aborts syncing, when sync isn't done.
X-Send-Pr-Version: 3.2

>Number:         5768
>Category:       kern
>Synopsis:       Shutdown aborts syncing, when sync isn't done.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 17 00:20:01 PST 1998
>Closed-Date:    Mon Jun 11 06:12:32 PDT 2001
>Last-Modified:  Mon Jun 11 06:12:46 PDT 2001
>Originator:     Kevin Day
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
DragonData Internet Services
>Environment:

2.2.x and -current

>Description:

	Quite often, when rebooting or shutting down a system, the drive is 
slowly syncing, but the kernel doesn't give it a chance to finish.

        Just tonight, I saw:

syncing disks: 
22 22 22 22 22 22 21 21 20 19 18 15 13 10 8 8 4 4 3 2 giving up....

It was obvious that it was going to finish, it just didn't give it enough of a 
chance.

>How-To-Repeat:

	I'm not sure why this happens sometimes, it just does. :)

>Fix:
	
        Here's a simple patch that makes it a bit more smart. If sync is 
making progress, don't stop it.

        I'm not too up on the current style/guidelines for kernel changes. 
Even though this is minor, feel free to show me the error of my ways if you 
disapprove. :)

--- kern_shutdown.c.orig	Tue Feb 17 01:52:07 1998
+++ kern_shutdown.c	Tue Feb 17 01:59:50 1998
@@ -211,6 +211,7 @@
 	if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) {
 		register struct buf *bp;
 		int iter, nbusy;
+		int lastnbusy = 0;
 
 		waittime = 0;
 		printf("\nsyncing disks... ");
@@ -228,6 +229,9 @@
 				break;
 			printf("%d ", nbusy);
 			DELAY(40000 * iter);
+		        if (lastnbusy > nbusy)
+		        	iter = 0;
+		        lastnbusy = nbusy;
 		}
 		if (nbusy) {
 			/*


This just stops it from giving up if it had recently made any progress.

I tried it quickly on here, and it seemed to work, but I don't know the 
ramifications for my actions. :)


Kevin

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Mon Jun 11 06:12:32 PDT 2001 
State-Changed-Why:  
Fixed in -CURRENT and -STABLE. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=5768 
>Unformatted:
