Deleted Added
full compact
kern_shutdown.c (65557) kern_shutdown.c (65707)
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.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
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.

--- 22 unchanged lines hidden (view full) ---

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94
39 * $FreeBSD: head/sys/kern/kern_shutdown.c 65557 2000-09-07 01:33:02Z jasone $
39 * $FreeBSD: head/sys/kern/kern_shutdown.c 65707 2000-09-10 23:06:50Z jasone $
40 */
41
42#include "opt_ddb.h"
43#include "opt_hw_wdog.h"
44#include "opt_panic.h"
45#include "opt_show_busybufs.h"
46
47#include <sys/param.h>

--- 166 unchanged lines hidden (view full) ---

214 */
215 EVENTHANDLER_INVOKE(shutdown_pre_sync, howto);
216
217 /*
218 * Now sync filesystems
219 */
220 if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) {
221 register struct buf *bp;
40 */
41
42#include "opt_ddb.h"
43#include "opt_hw_wdog.h"
44#include "opt_panic.h"
45#include "opt_show_busybufs.h"
46
47#include <sys/param.h>

--- 166 unchanged lines hidden (view full) ---

214 */
215 EVENTHANDLER_INVOKE(shutdown_pre_sync, howto);
216
217 /*
218 * Now sync filesystems
219 */
220 if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) {
221 register struct buf *bp;
222 int iter, nbusy;
222 int iter, nbusy, pbusy;
223 int subiter;
223
224 waittime = 0;
225 printf("\nsyncing disks... ");
226
227 sync(&proc0, NULL);
228
229 /*
230 * With soft updates, some buffers that are
231 * written will be remarked as dirty until other
232 * buffers are written.
233 */
224
225 waittime = 0;
226 printf("\nsyncing disks... ");
227
228 sync(&proc0, NULL);
229
230 /*
231 * With soft updates, some buffers that are
232 * written will be remarked as dirty until other
233 * buffers are written.
234 */
234 for (iter = 0; iter < 20; iter++) {
235 for (iter = pbusy = 0; iter < 20; iter++) {
235 nbusy = 0;
236 for (bp = &buf[nbuf]; --bp >= buf; ) {
237 if ((bp->b_flags & B_INVAL) == 0 &&
238 BUF_REFCNT(bp) > 0) {
239 nbusy++;
240 } else if ((bp->b_flags & (B_DELWRI | B_INVAL))
241 == B_DELWRI) {
242 /* bawrite(bp);*/
243 nbusy++;
244 }
245 }
246 if (nbusy == 0)
247 break;
248 printf("%d ", nbusy);
236 nbusy = 0;
237 for (bp = &buf[nbuf]; --bp >= buf; ) {
238 if ((bp->b_flags & B_INVAL) == 0 &&
239 BUF_REFCNT(bp) > 0) {
240 nbusy++;
241 } else if ((bp->b_flags & (B_DELWRI | B_INVAL))
242 == B_DELWRI) {
243 /* bawrite(bp);*/
244 nbusy++;
245 }
246 }
247 if (nbusy == 0)
248 break;
249 printf("%d ", nbusy);
250 if (nbusy < pbusy)
251 iter = 0;
252 pbusy = nbusy;
249 sync(&proc0, NULL);
253 sync(&proc0, NULL);
254 if (curproc != NULL) {
255 for (subiter = 0; subiter < 50 * iter; subiter++) {
256 mtx_enter(&sched_lock, MTX_SPIN);
257 setrunqueue(curproc);
258 mi_switch(); /* Allow interrupt threads to run */
259 mtx_exit(&sched_lock, MTX_SPIN);
260 DELAY(1000);
261 }
262 } else
250 DELAY(50000 * iter);
251 }
252 printf("\n");
253 /*
254 * Count only busy local buffers to prevent forcing
255 * a fsck if we're just a client of a wedged NFS server
256 */
257 nbusy = 0;

--- 349 unchanged lines hidden ---
263 DELAY(50000 * iter);
264 }
265 printf("\n");
266 /*
267 * Count only busy local buffers to prevent forcing
268 * a fsck if we're just a client of a wedged NFS server
269 */
270 nbusy = 0;

--- 349 unchanged lines hidden ---