summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2004-02-15 02:52:10 +0000
committertedu <tedu@openbsd.org>2004-02-15 02:52:10 +0000
commitba2bb9f40b8de9c1d3921014114b7fae675e6bd7 (patch)
tree42633f7378d95a386111de260f73e4bede13a2de
parentnew arg to disk_unbusy, to record separate read/write statistics. (diff)
downloadwireguard-openbsd-ba2bb9f40b8de9c1d3921014114b7fae675e6bd7.tar.xz
wireguard-openbsd-ba2bb9f40b8de9c1d3921014114b7fae675e6bd7.zip
knf
-rw-r--r--sys/dev/vnd.c67
1 files changed, 32 insertions, 35 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 3258fb7fc80..cc9e6157e8e 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.42 2004/02/15 02:45:46 tedu Exp $ */
+/* $OpenBSD: vnd.c,v 1.43 2004/02/15 02:52:10 tedu Exp $ */
/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
@@ -87,19 +87,19 @@
#ifdef DEBUG
int dovndcluster = 1;
int vnddebug = 0x00;
-#define VDB_FOLLOW 0x01
-#define VDB_INIT 0x02
-#define VDB_IO 0x04
+#define VDB_FOLLOW 0x01
+#define VDB_INIT 0x02
+#define VDB_IO 0x04
#endif
-#define b_cylin b_resid
+#define b_cylin b_resid
/*
* vndunit is a bit weird. have to reconstitute the dev_t for
* DISKUNIT(), but with the minor masked off.
*/
#define vndunit(x) DISKUNIT(makedev(major(x), minor(x) & 0x7ff))
-#define vndsimple(x) (minor(x) & 0x800)
+#define vndsimple(x) (minor(x) & 0x800)
#define MAKEVNDDEV(maj, unit, part) MAKEDISKDEV(maj, unit, part)
#define VNDLABELDEV(dev) (MAKEVNDDEV(major(dev), vndunit(dev), RAW_PART))
@@ -111,7 +111,7 @@ struct vndbuf {
#define getvndbuf() \
((struct vndbuf *)malloc(sizeof(struct vndbuf), M_DEVBUF, M_WAITOK))
-#define putvndbuf(vbp) \
+#define putvndbuf(vbp) \
free((caddr_t)(vbp), M_DEVBUF)
struct vnd_softc {
@@ -129,14 +129,14 @@ struct vnd_softc {
/* sc_flags */
#define VNF_ALIVE 0x0001
-#define VNF_INITED 0x0002
-#define VNF_WANTED 0x0040
-#define VNF_LOCKED 0x0080
+#define VNF_INITED 0x0002
+#define VNF_WANTED 0x0040
+#define VNF_LOCKED 0x0080
#define VNF_LABELLING 0x0100
#define VNF_WLABEL 0x0200
#define VNF_HAVELABEL 0x0400
-#define VNF_BUSY 0x0800
-#define VNF_SIMPLE 0x1000
+#define VNF_BUSY 0x0800
+#define VNF_SIMPLE 0x1000
struct vnd_softc *vnd_softc;
int numvnd = 0;
@@ -160,15 +160,15 @@ void vndunlock(struct vnd_softc *);
void
vndencrypt(vnd, addr, size, off, encrypt)
- struct vnd_softc *vnd;
- caddr_t addr;
- size_t size;
- daddr_t off;
- int encrypt;
+ struct vnd_softc *vnd;
+ caddr_t addr;
+ size_t size;
+ daddr_t off;
+ int encrypt;
{
int i, bsize;
u_char iv[8];
-
+
bsize = dbtob(1);
for (i = 0; i < size/bsize; i++) {
bzero(iv, sizeof(iv));
@@ -478,21 +478,18 @@ vndstrategy(bp)
vnd->sc_cred);
if (vnd->sc_keyctx)
vndencrypt(vnd, bp->b_data,
- bp->b_bcount,
- bp->b_blkno, 0);
+ bp->b_bcount, bp->b_blkno, 0);
} else {
if (vnd->sc_keyctx)
vndencrypt(vnd, bp->b_data,
- bp->b_bcount,
- bp->b_blkno, 1);
+ bp->b_bcount, bp->b_blkno, 1);
auio.uio_rw = UIO_WRITE;
bp->b_error = VOP_WRITE(vnd->sc_vp, &auio, 0,
vnd->sc_cred);
/* Data in buffer cache needs to be in clear */
if (vnd->sc_keyctx)
vndencrypt(vnd, bp->b_data,
- bp->b_bcount,
- bp->b_blkno, 0);
+ bp->b_bcount, bp->b_blkno, 0);
}
vnd->sc_flags &= ~VNF_BUSY;
VOP_UNLOCK(vnd->sc_vp, 0, p);
@@ -522,7 +519,7 @@ vndstrategy(bp)
/* The old-style buffercache bypassing method. */
bn += vnd->sc_dk.dk_label->d_partitions[DISKPART(bp->b_dev)].p_offset;
bn = dbtob(bn);
- bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
+ bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
addr = bp->b_data;
flags = bp->b_flags | B_CALL;
for (resid = bp->b_resid; resid; resid -= sz) {
@@ -550,7 +547,7 @@ vndstrategy(bp)
#ifdef DEBUG
if (vnddebug & VDB_IO)
printf("vndstrategy: vp %p/%p bn %x/%x sz %x\n",
- vnd->sc_vp, vp, bn, nbn, sz);
+ vnd->sc_vp, vp, bn, nbn, sz);
#endif
nbp = getvndbuf();
@@ -680,13 +677,13 @@ vndiodone(bp)
else
vnd->sc_tab.b_active--;
}
- if (pbp->b_resid == 0) {
+ if (pbp->b_resid == 0) {
#ifdef DEBUG
- if (vnddebug & VDB_IO)
- printf("vndiodone: pbp %p iodone\n", pbp);
+ if (vnddebug & VDB_IO)
+ printf("vndiodone: pbp %p iodone\n", pbp);
#endif
- biodone(pbp);
- }
+ biodone(pbp);
+ }
}
@@ -820,21 +817,21 @@ vndioctl(dev, cmd, addr, flag, p)
key = malloc(vio->vnd_keylen, M_TEMP, M_WAITOK);
if ((error = copyin((caddr_t)vio->vnd_key, key,
- vio->vnd_keylen)) != 0) {
+ vio->vnd_keylen)) != 0) {
(void) vn_close(nd.ni_vp, FREAD|FWRITE,
- p->p_ucred, p);
+ p->p_ucred, p);
vndunlock(vnd);
return (error);
}
vnd->sc_keyctx = malloc(sizeof(blf_ctx), M_DEVBUF,
- M_WAITOK);
+ M_WAITOK);
blf_key(vnd->sc_keyctx, key, vio->vnd_keylen);
bzero(key, vio->vnd_keylen);
free((caddr_t)key, M_TEMP);
} else
vnd->sc_keyctx = NULL;
-
+
vndthrottle(vnd, vnd->sc_vp);
vio->vnd_size = dbtob((off_t)vnd->sc_size);
vnd->sc_flags |= VNF_INITED;