kern_shutdown.c (132866) | kern_shutdown.c (133418) |
---|---|
1/*- 2 * Copyright (c) 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 35 */ 36 37#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1986, 1988, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 21 unchanged lines hidden (view full) --- 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 35 */ 36 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/sys/kern/kern_shutdown.c 132866 2004-07-30 01:30:05Z njl $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_shutdown.c 133418 2004-08-10 01:32:05Z njl $"); |
39 40#include "opt_kdb.h" 41#include "opt_hw_wdog.h" 42#include "opt_mac.h" 43#include "opt_panic.h" 44#include "opt_show_busybufs.h" 45 46#include <sys/param.h> --- 203 unchanged lines hidden (view full) --- 250/* 251 * Go through the rigmarole of shutting down.. 252 * this used to be in machdep.c but I'll be dammned if I could see 253 * anything machine dependant in it. 254 */ 255static void 256boot(int howto) 257{ | 39 40#include "opt_kdb.h" 41#include "opt_hw_wdog.h" 42#include "opt_mac.h" 43#include "opt_panic.h" 44#include "opt_show_busybufs.h" 45 46#include <sys/param.h> --- 203 unchanged lines hidden (view full) --- 250/* 251 * Go through the rigmarole of shutting down.. 252 * this used to be in machdep.c but I'll be dammned if I could see 253 * anything machine dependant in it. 254 */ 255static void 256boot(int howto) 257{ |
258 static int first_buf_printf = 1; | |
259 260 /* collect extra flags that shutdown_nice might have set */ 261 howto |= shutdown_howto; 262 263 /* We are out of the debugger now. */ 264 kdb_active = 0; 265 266#ifdef SMP --- 10 unchanged lines hidden (view full) --- 277 */ 278 if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) { 279 register struct buf *bp; 280 int iter, nbusy, pbusy; 281#ifndef PREEMPTION 282 int subiter; 283#endif 284 | 258 259 /* collect extra flags that shutdown_nice might have set */ 260 howto |= shutdown_howto; 261 262 /* We are out of the debugger now. */ 263 kdb_active = 0; 264 265#ifdef SMP --- 10 unchanged lines hidden (view full) --- 276 */ 277 if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) { 278 register struct buf *bp; 279 int iter, nbusy, pbusy; 280#ifndef PREEMPTION 281 int subiter; 282#endif 283 |
284 for (nbusy = 0, bp = &buf[nbuf]; --bp >= buf; ) 285 if (((bp->b_flags & B_INVAL) == 0 && 286 BUF_REFCNT(bp) > 0) || 287 ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) 288 nbusy++; 289 if (nbusy == 0) { 290 printf("Skipping final sync, no buffers remaining\n"); 291 goto unmountall; 292 } 293 |
|
285 waittime = 0; | 294 waittime = 0; |
295 printf("Syncing disks, buffers remaining... "); |
|
286 287 sync(&thread0, NULL); 288 289 /* 290 * With soft updates, some buffers that are 291 * written will be remarked as dirty until other 292 * buffers are written. 293 */ --- 6 unchanged lines hidden (view full) --- 300 } else if ((bp->b_flags & (B_DELWRI | B_INVAL)) 301 == B_DELWRI) { 302 /* bawrite(bp);*/ 303 nbusy++; 304 } 305 } 306 if (nbusy == 0) 307 break; | 296 297 sync(&thread0, NULL); 298 299 /* 300 * With soft updates, some buffers that are 301 * written will be remarked as dirty until other 302 * buffers are written. 303 */ --- 6 unchanged lines hidden (view full) --- 310 } else if ((bp->b_flags & (B_DELWRI | B_INVAL)) 311 == B_DELWRI) { 312 /* bawrite(bp);*/ 313 nbusy++; 314 } 315 } 316 if (nbusy == 0) 317 break; |
308 if (first_buf_printf) { 309 printf("syncing disks, buffers remaining... "); 310 first_buf_printf = 0; 311 } | |
312 printf("%d ", nbusy); 313 if (nbusy < pbusy) 314 iter = 0; 315 pbusy = nbusy; 316 sync(&thread0, NULL); 317 318#ifdef PREEMPTION 319 /* --- 13 unchanged lines hidden (view full) --- 333 mtx_lock_spin(&sched_lock); 334 mi_switch(SW_VOL, NULL); 335 mtx_unlock_spin(&sched_lock); 336 DELAY(1000); 337 } 338 PICKUP_GIANT(); 339#endif 340 } | 318 printf("%d ", nbusy); 319 if (nbusy < pbusy) 320 iter = 0; 321 pbusy = nbusy; 322 sync(&thread0, NULL); 323 324#ifdef PREEMPTION 325 /* --- 13 unchanged lines hidden (view full) --- 339 mtx_lock_spin(&sched_lock); 340 mi_switch(SW_VOL, NULL); 341 mtx_unlock_spin(&sched_lock); 342 DELAY(1000); 343 } 344 PICKUP_GIANT(); 345#endif 346 } |
347 printf("\n"); |
|
341 342 /* 343 * Count only busy local buffers to prevent forcing 344 * a fsck if we're just a client of a wedged NFS server 345 */ 346 nbusy = 0; 347 for (bp = &buf[nbuf]; --bp >= buf; ) { 348 if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) || --- 19 unchanged lines hidden (view full) --- 368 * unmount filesystems (thus forcing an fsck on reboot). 369 */ 370 printf("giving up on %d buffers\n", nbusy); 371 DELAY(5000000); /* 5 seconds */ 372 } else { 373 /* 374 * Unmount filesystems 375 */ | 348 349 /* 350 * Count only busy local buffers to prevent forcing 351 * a fsck if we're just a client of a wedged NFS server 352 */ 353 nbusy = 0; 354 for (bp = &buf[nbuf]; --bp >= buf; ) { 355 if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) || --- 19 unchanged lines hidden (view full) --- 375 * unmount filesystems (thus forcing an fsck on reboot). 376 */ 377 printf("giving up on %d buffers\n", nbusy); 378 DELAY(5000000); /* 5 seconds */ 379 } else { 380 /* 381 * Unmount filesystems 382 */ |
383unmountall: |
|
376 if (panicstr == 0) 377 vfs_unmountall(); 378 } 379 DELAY(100000); /* wait for console output to finish */ 380 } 381 382 print_uptime(); 383 --- 248 unchanged lines hidden --- | 384 if (panicstr == 0) 385 vfs_unmountall(); 386 } 387 DELAY(100000); /* wait for console output to finish */ 388 } 389 390 print_uptime(); 391 --- 248 unchanged lines hidden --- |