Permalink
Browse files

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.
  • Loading branch information...
Matthew Dillon
Matthew Dillon committed Apr 25, 2011
1 parent d5ec417 commit 9a044c9b5fd13be644170e76f75a73ce7206666f
Showing with 35 additions and 1 deletion.
  1. +35 −1 sys/kern/kern_shutdown.c
View
@@ -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,19 +403,52 @@ 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)
return (1);
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)) {
/*

0 comments on commit 9a044c9

Please sign in to comment.