summaryrefslogtreecommitdiff
path: root/sys/dev/vnd.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-12 20:21:37 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-12 20:21:37 +0000
commit6c3c7152302dce08b17b6fac14272fc435778145 (patch)
treecee094e02a544a7c9210d26eeda5c006c750989b /sys/dev/vnd.c
parent484706ec2d7791c35fcf9aea53e46db186855c74 (diff)
from netbsd;
New generic disk framework. Highlights: New metrics handling. Metrics are now kept in the new `struct disk'. Busy time is now stored as a timeval, and transfer count in bytes. Storage for disklabels is now dynamically allocated, so that the size of the disk structure is not machine-dependent. Several new functions for attaching and detaching disks, and handling metrics calculation. Old-style instrumentation is still supported in drivers that did it before. However, old-style instrumentation is being deprecated, and will go away once the userland utilities are updated for the new framework. For usage and architectural details, see the forthcoming disk(9) manual page.
Diffstat (limited to 'sys/dev/vnd.c')
-rw-r--r--sys/dev/vnd.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 52b32f5eca8..921ca9981cb 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.22 1995/11/06 20:28:09 thorpej Exp $ */
+/* $NetBSD: vnd.c,v 1.23 1996/01/07 22:03:33 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -66,7 +66,6 @@
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/errno.h>
-#include <sys/dkstat.h>
#include <sys/buf.h>
#include <sys/malloc.h>
#include <sys/ioctl.h>
@@ -113,7 +112,8 @@ struct vnd_softc {
struct ucred *sc_cred; /* credentials */
int sc_maxactive; /* max # of active requests */
struct buf sc_tab; /* transfer queue */
- struct dkdevice sc_dkdev; /* generic disk device info */
+ char sc_xname[8]; /* XXX external name */
+ struct disk sc_dkdev; /* generic disk device info */
};
/* sc_flags */
@@ -400,6 +400,10 @@ vndstart(vnd)
vnd-vnd_softc, bp, bp->b_vp, bp->b_blkno, bp->b_data,
bp->b_bcount);
#endif
+
+ /* Instrumentation. */
+ disk_busy(&vnd->sc_dkdev);
+
if ((bp->b_flags & B_READ) == 0)
bp->b_vp->v_numoutput++;
VOP_STRATEGY(bp);
@@ -420,6 +424,7 @@ vndiodone(vbp)
vnd-vnd_softc, vbp, vbp->vb_buf.b_vp, vbp->vb_buf.b_blkno,
vbp->vb_buf.b_data, vbp->vb_buf.b_bcount);
#endif
+
if (vbp->vb_buf.b_error) {
#ifdef DEBUG
if (vnddebug & VDB_IO)
@@ -431,6 +436,7 @@ vndiodone(vbp)
}
pbp->b_resid -= vbp->vb_buf.b_bcount;
putvndbuf(vbp);
+ disk_unbusy(&vnd->sc_dkdev, (pbp->b_bcount - pbp->b_resid));
if (pbp->b_resid == 0) {
#ifdef DEBUG
if (vnddebug & VDB_IO)
@@ -567,6 +573,12 @@ vndioctl(dev, cmd, data, flag, p)
vnd->sc_vp, vnd->sc_size);
#endif
+ /* Attach the disk. */
+ bzero(vnd->sc_xname, sizeof(vnd->sc_xname)); /* XXX */
+ sprintf(vnd->sc_xname, "vnd%d", unit); /* XXX */
+ vnd->sc_dkdev.dk_name = vnd->sc_xname;
+ disk_attach(&vnd->sc_dkdev);
+
vndunlock(vnd);
break;
@@ -598,6 +610,9 @@ vndioctl(dev, cmd, data, flag, p)
printf("vndioctl: CLRed\n");
#endif
+ /* Detatch the disk. */
+ disk_detatch(&vnd->sc_dkdev);
+
/* This must be atomic. */
s = splhigh();
vndunlock(vnd);