kern_shutdown.c (133418) | kern_shutdown.c (133763) |
---|---|
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 133418 2004-08-10 01:32:05Z njl $"); | 38__FBSDID("$FreeBSD: head/sys/kern/kern_shutdown.c 133763 2004-08-15 19:17:23Z truckman $"); |
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; |
|
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 | 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 |
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 | |
294 waittime = 0; | 285 waittime = 0; |
295 printf("Syncing disks, buffers remaining... "); | |
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 */ --- 4 unchanged lines hidden (view full) --- 308 BUF_REFCNT(bp) > 0) { 309 nbusy++; 310 } else if ((bp->b_flags & (B_DELWRI | B_INVAL)) 311 == B_DELWRI) { 312 /* bawrite(bp);*/ 313 nbusy++; 314 } 315 } | 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 */ --- 4 unchanged lines hidden (view full) --- 298 BUF_REFCNT(bp) > 0) { 299 nbusy++; 300 } else if ((bp->b_flags & (B_DELWRI | B_INVAL)) 301 == B_DELWRI) { 302 /* bawrite(bp);*/ 303 nbusy++; 304 } 305 } |
316 if (nbusy == 0) | 306 if (nbusy == 0) { 307 if (first_buf_printf) 308 printf("No buffers busy after final sync"); |
317 break; | 309 break; |
310 } 311 if (first_buf_printf) { 312 printf("Syncing disks, buffers remaining... "); 313 first_buf_printf = 0; 314 } |
|
318 printf("%d ", nbusy); 319 if (nbusy < pbusy) 320 iter = 0; 321 pbusy = nbusy; 322 sync(&thread0, NULL); 323 324#ifdef PREEMPTION 325 /* --- 14 unchanged lines hidden (view full) --- 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"); | 315 printf("%d ", nbusy); 316 if (nbusy < pbusy) 317 iter = 0; 318 pbusy = nbusy; 319 sync(&thread0, NULL); 320 321#ifdef PREEMPTION 322 /* --- 14 unchanged lines hidden (view full) --- 337 mi_switch(SW_VOL, NULL); 338 mtx_unlock_spin(&sched_lock); 339 DELAY(1000); 340 } 341 PICKUP_GIANT(); 342#endif 343 } 344 printf("\n"); |
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)) || 356 ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) { --- 12 unchanged lines hidden (view full) --- 369#endif 370 } 371 } 372 if (nbusy) { 373 /* 374 * Failed to sync all blocks. Indicate this and don't 375 * unmount filesystems (thus forcing an fsck on reboot). 376 */ | 345 /* 346 * Count only busy local buffers to prevent forcing 347 * a fsck if we're just a client of a wedged NFS server 348 */ 349 nbusy = 0; 350 for (bp = &buf[nbuf]; --bp >= buf; ) { 351 if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) || 352 ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) { --- 12 unchanged lines hidden (view full) --- 365#endif 366 } 367 } 368 if (nbusy) { 369 /* 370 * Failed to sync all blocks. Indicate this and don't 371 * unmount filesystems (thus forcing an fsck on reboot). 372 */ |
377 printf("giving up on %d buffers\n", nbusy); | 373 printf("Giving up on %d buffers\n", nbusy); |
378 DELAY(5000000); /* 5 seconds */ 379 } else { | 374 DELAY(5000000); /* 5 seconds */ 375 } else { |
376 if (!first_buf_printf) 377 printf("Final sync complete\n"); |
|
380 /* 381 * Unmount filesystems 382 */ | 378 /* 379 * Unmount filesystems 380 */ |
383unmountall: | |
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 --- | 381 if (panicstr == 0) 382 vfs_unmountall(); 383 } 384 DELAY(100000); /* wait for console output to finish */ 385 } 386 387 print_uptime(); 388 --- 248 unchanged lines hidden --- |