diff options
-rw-r--r-- | sys/kern/vfs_subr.c | 44 | ||||
-rw-r--r-- | sys/sys/vnode.h | 23 |
2 files changed, 31 insertions, 36 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 5b6ca33f3c9..c1702e63ab4 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.51 2001/02/24 19:07:08 csapuntz Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.52 2001/02/26 00:18:33 csapuntz Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -705,7 +705,7 @@ vref(vp) struct vnode *vp; { simple_lock(&vp->v_interlock); - if (vp->v_usecount <= 0) + if (vp->v_usecount == 0) panic("vref used where vget required"); vp->v_usecount++; simple_unlock(&vp->v_interlock); @@ -766,18 +766,19 @@ vput(vp) panic("vput: null vp"); #endif simple_lock(&vp->v_interlock); + +#ifdef DIAGNOSTIC + if (vp->v_usecount == 0 || vp->v_writecount != 0) { + vprint("vput: bad ref count", vp); + panic("vput: ref cnt"); + } +#endif vp->v_usecount--; if (vp->v_usecount > 0) { simple_unlock(&vp->v_interlock); VOP_UNLOCK(vp, 0, p); return; } -#ifdef DIAGNOSTIC - if (vp->v_usecount < 0 || vp->v_writecount != 0) { - vprint("vput: bad ref count", vp); - panic("vput: ref cnt"); - } -#endif vputonfreelist(vp); @@ -801,17 +802,17 @@ vrele(vp) panic("vrele: null vp"); #endif simple_lock(&vp->v_interlock); - vp->v_usecount--; - if (vp->v_usecount > 0) { - simple_unlock(&vp->v_interlock); - return; - } #ifdef DIAGNOSTIC - if (vp->v_usecount < 0 || vp->v_writecount != 0) { + if (vp->v_usecount == 0 || vp->v_writecount != 0) { vprint("vrele: bad ref count", vp); panic("vrele: ref cnt"); } #endif + vp->v_usecount--; + if (vp->v_usecount > 0) { + simple_unlock(&vp->v_interlock); + return; + } vputonfreelist(vp); @@ -1265,7 +1266,7 @@ vprint(label, vp) if (label != NULL) printf("%s: ", label); - printf("type %s, usecount %d, writecount %d, holdcount %ld,", + printf("type %s, usecount %u, writecount %u, holdcount %u,", typename[vp->v_type], vp->v_usecount, vp->v_writecount, vp->v_holdcnt); buf[0] = '\0'; @@ -1874,17 +1875,17 @@ fs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) * Manipulates v_numoutput. Must be called at splbio() */ int -vwaitforio(vp, slpflag, wchan, timeo) +vwaitforio(vp, slpflag, wmesg, timeo) struct vnode *vp; int slpflag, timeo; - char *wchan; + char *wmesg; { int error = 0; while (vp->v_numoutput) { vp->v_bioflag |= VBIOWAIT; error = tsleep((caddr_t)&vp->v_numoutput, - slpflag | (PRIBIO + 1), wchan, timeo); + slpflag | (PRIBIO + 1), wmesg, timeo); if (error) break; } @@ -1903,9 +1904,9 @@ vwakeup(vp) struct vnode *vp; { if (vp != NULL) { - if (--vp->v_numoutput < 0) + if (vp->v_numoutput-- == 0) panic("vwakeup: neg numoutput"); - if ((vp->v_bioflag & VBIOWAIT) && vp->v_numoutput <= 0) { + if ((vp->v_bioflag & VBIOWAIT) && vp->v_numoutput == 0) { vp->v_bioflag &= ~VBIOWAIT; wakeup((caddr_t)&vp->v_numoutput); } @@ -2086,10 +2087,9 @@ brelvp(bp) simple_lock(&vp->v_interlock); #ifdef DIAGNOSTIC - if (vp->v_holdcnt <= 0) + if (vp->v_holdcnt == 0) panic("brelvp: holdcnt"); #endif - vp->v_holdcnt--; /* diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 500339dbca7..0e16c8eb6c6 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.29 2001/02/24 19:07:07 csapuntz Exp $ */ +/* $OpenBSD: vnode.h,v 1.30 2001/02/26 00:18:32 csapuntz Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -90,23 +90,23 @@ struct vnode { #ifdef UVM struct uvm_vnode v_uvm; /* uvm data */ #endif + int (**v_op) __P((void *)); /* vnode operations vector */ + enum vtype v_type; /* vnode type */ u_int32_t v_flag; /* vnode flags (see below) */ - int v_usecount; /* reference count of users */ - int v_writecount; /* reference count of writers */ + u_int32_t v_usecount; /* reference count of users */ + u_int32_t v_writecount; /* reference count of writers */ u_int32_t v_bioflag; /* flags that can be read/written at interrupt level */ - long v_holdcnt; /* page & buffer references */ - u_long v_id; /* capability identifier */ + u_int32_t v_holdcnt; /* buffer references */ + u_int32_t v_id; /* capability identifier */ struct mount *v_mount; /* ptr to vfs we are in */ - int (**v_op) __P((void *)); /* vnode operations vector */ TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ LIST_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ - long v_numoutput; /* num of writes in progress */ + u_int32_t v_numoutput; /* num of writes in progress */ LIST_ENTRY(vnode) v_synclist; /* vnode with dirty buffers */ - enum vtype v_type; /* vnode type */ union { struct mount *vu_mountedhere;/* ptr to mounted vfs (VDIR) */ struct socket *vu_socket; /* unix ipc (VSOCK) */ @@ -117,10 +117,6 @@ struct vnode { struct simplelock v_interlock; /* lock on usecount and flag */ struct lock *v_vnlock; /* used for non-locking fs's */ -#ifdef UVM -#else - long v_spare[3]; /* round to 128 bytes */ -#endif enum vtagtype v_tag; /* type of underlying data */ void *v_data; /* private data for fs */ struct { @@ -239,8 +235,6 @@ extern struct simplelock vnode_free_list_slock; #ifdef DIAGNOSTIC #define VATTR_NULL(vap) vattr_null(vap) -void vattr_null __P((struct vattr *vap)); - #define VREF(vp) vref(vp) void vref __P((struct vnode *)); @@ -421,6 +415,7 @@ int getnewvnode __P((enum vtagtype tag, struct mount *mp, int (**vops) __P((void *)), struct vnode **vpp)); int getvnode __P((struct filedesc *fdp, int fd, struct file **fpp)); void getnewfsid __P((struct mount *, int)); +void vattr_null __P((struct vattr *vap)); int vcount __P((struct vnode *vp)); int vfinddev __P((dev_t, enum vtype, struct vnode **)); void vflushbuf __P((struct vnode *vp, int sync)); |