cvs commit: src/sys/kern kern_shutdown.c vfs_subr.c

Don Lewis truckman at FreeBSD.org
Sun Jul 18 22:43:47 PDT 2004


On 14 Jul, Alfred Perlstein wrote:
> * Don Lewis <truckman at FreeBSD.org> [040714 22:46] wrote:

>> I'd prefer skipping the the final sync() in boot() if there are no dirty
>> buffers, with a message something like "skipping final sync because no
>> dirty buffers remain".
> 
> Diffs welcome!

Note: I revived the printf("\n") mostly so that the SHOW_BUSYBUFS output
would be formatted correctly.

Index: sys/kern/kern_shutdown.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_shutdown.c,v
retrieving revision 1.157
diff -u -r1.157 kern_shutdown.c
--- sys/kern/kern_shutdown.c	15 Jul 2004 08:01:00 -0000	1.157
+++ sys/kern/kern_shutdown.c	19 Jul 2004 05:18:15 -0000
@@ -245,7 +245,6 @@
 static void
 boot(int howto)
 {
-	static int first_buf_printf = 1;
 
 	/* collect extra flags that shutdown_nice might have set */
 	howto |= shutdown_howto;
@@ -272,7 +271,18 @@
 		int subiter;
 #endif
 
+		for (nbusy = 0, bp = &buf[nbuf]; --bp >= buf; )
+			if (((bp->b_flags & B_INVAL) == 0 &&
+			    BUF_REFCNT(bp) > 0) ||
+			    ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI))
+					nbusy++;
+		if (nbusy == 0) {
+			printf("Skipping final sync, no buffers remaining.\n");
+			goto unmountall;
+		}
+
 		waittime = 0;
+		printf("Syncing disks, buffers remaining... ");
 
 		sync(&thread0, NULL);
 
@@ -295,10 +305,6 @@
 			}
 			if (nbusy == 0)
 				break;
-			if (first_buf_printf) {
-				printf("syncing disks, buffers remaining... ");
-				first_buf_printf = 0;
-			}
 			printf("%d ", nbusy);
 			if (nbusy < pbusy)
 				iter = 0;
@@ -328,7 +334,7 @@
 			PICKUP_GIANT();
 #endif
 		}
-
+		printf("\n");
 		/*
 		 * Count only busy local buffers to prevent forcing 
 		 * a fsck if we're just a client of a wedged NFS server
@@ -357,13 +363,14 @@
 			 * Failed to sync all blocks. Indicate this and don't
 			 * unmount filesystems (thus forcing an fsck on reboot).
 			 */
-			printf("giving up on %d buffers\n", nbusy);
+			printf("Giving up on %d buffers.\n", nbusy);
 			DELAY(5000000);	/* 5 seconds */
 		} else {
-			printf("done\n");
+			printf("Final sync complete.\n");
 			/*
 			 * Unmount filesystems
 			 */
+unmountall:
 			if (panicstr == 0)
 				vfs_unmountall();
 		}





More information about the cvs-all mailing list