From 4ac83a78035180de2607ca178e0cbe347ba705b6 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 25 Apr 2011 11:43:52 -0700 Subject: [PATCH] kernel - Try to reduce 'busy buffers problems' during halt/reboot * Ignore busy buffers related to TMPFS in pass 1, and busy buffers related to TMPFS, NFS, SMBFS, and MFS in the final check. --- sys/kern/kern_shutdown.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 3e147731cb..39a214bbe4 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -364,7 +364,8 @@ boot(int howto) */ kprintf("giving up on %d buffers\n", nbusy); #ifdef DDB - Debugger("busy buffer problem"); + if (debugger_on_panic) + Debugger("busy buffer problem"); #endif /* DDB */ tsleep(boot, 0, "shutdn", hz * 5 + 1); } else { @@ -402,9 +403,18 @@ boot(int howto) /* NOTREACHED */ } +/* + * Pass 1 - Figure out if there are any busy or dirty buffers still present. + * + * We ignore TMPFS mounts in this pass. + */ static int shutdown_busycount1(struct buf *bp, void *info) { + struct vnode *vp; + + if ((vp = bp->b_vp) != NULL && vp->v_tag == VT_TMPFS) + return (0); if ((bp->b_flags & B_INVAL) == 0 && BUF_REFCNT(bp) > 0) return(1); if ((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI) @@ -412,9 +422,33 @@ shutdown_busycount1(struct buf *bp, void *info) return (0); } +/* + * Pass 2 - only run after pass 1 has completed or has given up + * + * We ignore TMPFS, NFS, MFS, and SMBFS mounts in this pass. + */ static int shutdown_busycount2(struct buf *bp, void *info) { + struct vnode *vp; + + /* + * Ignore tmpfs and nfs mounts + */ + if ((vp = bp->b_vp) != NULL) { + if (vp->v_tag == VT_TMPFS) + return (0); + if (vp->v_tag == VT_NFS) + return (0); + if (vp->v_tag == VT_MFS) + return (0); + if (vp->v_tag == VT_SMBFS) + return (0); + } + + /* + * Only count buffers stuck on I/O, ignore everything else + */ if (((bp->b_flags & B_INVAL) == 0 && BUF_REFCNT(bp)) || ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) { /* -- 2.41.0