/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <miscfs/specfs/specdev.h>
#include <vfs/vfs_support.h>
+#include <sys/kdebug.h>
struct vnode *speclisth[SPECHSZ];
int a_which;
int a_fflags;
struct ucred *a_cred;
+ void * a_wql;
struct proc *a_p;
} */ *ap;
{
case VCHR:
dev = ap->a_vp->v_rdev;
- return (*cdevsw[major(dev)].d_select)(dev, ap->a_which, ap->a_p);
+ return (*cdevsw[major(dev)].d_select)(dev, ap->a_which, ap->a_wql, ap->a_p);
}
}
/*
s = splbio();
for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) {
nbp = bp->b_vnbufs.le_next;
- if ((bp->b_flags & B_BUSY))
+ // XXXdbg - don't flush locked blocks. they may be journaled.
+ if ((bp->b_flags & B_BUSY) || (bp->b_flags & B_LOCKED))
continue;
if ((bp->b_flags & B_DELWRI) == 0)
panic("spec_fsync: not dirty");
struct buf *a_bp;
} */ *ap;
{
- (*bdevsw[major(ap->a_bp->b_dev)].d_strategy)(ap->a_bp);
- return (0);
+ struct buf *bp;
+
+ bp = ap->a_bp;
+
+ if (kdebug_enable) {
+ int code = 0;
+
+ if (bp->b_flags & B_READ)
+ code |= DKIO_READ;
+ if (bp->b_flags & B_ASYNC)
+ code |= DKIO_ASYNC;
+
+ if (bp->b_flags & B_META)
+ code |= DKIO_META;
+ else if (bp->b_flags & (B_PGIN | B_PAGEOUT))
+ code |= DKIO_PAGING;
+
+ KERNEL_DEBUG_CONSTANT(FSDBG_CODE(DBG_DKRW, code) | DBG_FUNC_NONE,
+ bp, bp->b_dev, bp->b_blkno, bp->b_bcount, 0);
+ }
+ (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
+ return (0);
}
/*
*/
if (vcount(vp) == 2 && ap->a_p &&
vp == ap->a_p->p_session->s_ttyvp) {
- vrele(vp);
ap->a_p->p_session->s_ttyvp = NULL;
+ vrele(vp);
}
/*
* If the vnode is locked, then we are in the midst
break;
case VBLK:
+#ifdef DEVFS_IMPLEMENTS_LOCKING
/*
* On last close of a block device (that isn't mounted)
* we must invalidate any in core blocks, so that
* we can, for instance, change floppy disks.
*/
- if (error = vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 0, 0))
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, ap->a_p);
+ error = vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 0, 0);
+ VOP_UNLOCK(vp, 0, ap->a_p);
+ if (error)
return (error);
/*
* We do not want to really close the device if it
*/
if (vcount(vp) > 1 && (vp->v_flag & VXLOCK) == 0)
return (0);
+#else /* DEVFS_IMPLEMENTS_LOCKING */
+ /*
+ * We do not want to really close the device if it
+ * is still in use unless we are trying to close it
+ * forcibly. Since every use (buffer, vnode, swap, cmap)
+ * holds a reference to the vnode, and because we mark
+ * any other vnodes that alias this device, when the
+ * sum of the reference counts on all the aliased
+ * vnodes descends to one, we are on last close.
+ */
+ if (vcount(vp) > 1 && (vp->v_flag & VXLOCK) == 0)
+ return (0);
+
+ /*
+ * On last close of a block device (that isn't mounted)
+ * we must invalidate any in core blocks, so that
+ * we can, for instance, change floppy disks.
+ */
+ error = vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 0, 0);
+ if (error)
+ return (error);
+#endif /* DEVFS_IMPLEMENTS_LOCKING */
devclose = bdevsw[major(dev)].d_close;
mode = S_IFBLK;
break;