diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-12-19 08:58:08 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-12-19 08:58:08 +0000 |
commit | d8afae924f4db99650aa0df115c6ae66ed02b950 (patch) | |
tree | a2cbc045f0eb624a394f8e45fea1a58ecf1faaf0 /sys/kern/vfs_subr.c | |
parent | 4a6c79ff4f05aaae32458104529a9a9e0d3d208b (diff) |
UBC was a disaster. It worked very good when it worked, but on some
machines or some configurations or in some phase of the moon (we actually
don't know when or why) files disappeared. Since we've not been able to
track down the problem in two weeks intense debugging and we need -current
to be stable, back out everything to a state it had before UBC.
We apologise for the inconvenience.
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r-- | sys/kern/vfs_subr.c | 150 |
1 files changed, 46 insertions, 104 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 7d000db08bf..aaff1342b67 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.79 2001/12/10 18:47:16 art Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.80 2001/12/19 08:58:06 art Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -377,8 +377,6 @@ getnewvnode(tag, mp, vops, vpp) int (**vops) __P((void *)); struct vnode **vpp; { - extern struct uvm_pagerops uvm_vnodeops; - struct uvm_object *uobj; struct proc *p = curproc; /* XXX */ struct freelst *listhd; static int toggle; @@ -412,17 +410,11 @@ getnewvnode(tag, mp, vops, vpp) splx(s); simple_unlock(&vnode_free_list_slock); vp = pool_get(&vnode_pool, PR_WAITOK); - bzero(vp, sizeof *vp); - /* - * initialize uvm_object within vnode. - */ - uobj = &vp->v_uobj; - uobj->pgops = &uvm_vnodeops; - uobj->uo_npages = 0; - TAILQ_INIT(&uobj->memq); + bzero((char *)vp, sizeof *vp); numvnodes++; } else { - TAILQ_FOREACH(vp, listhd, v_freelist) { + for (vp = TAILQ_FIRST(listhd); vp != NULLVP; + vp = TAILQ_NEXT(vp, v_freelist)) { if (simple_lock_try(&vp->v_interlock)) break; } @@ -453,13 +445,14 @@ getnewvnode(tag, mp, vops, vpp) else simple_unlock(&vp->v_interlock); #ifdef DIAGNOSTIC - if (vp->v_data || vp->v_uobj.uo_npages || - TAILQ_FIRST(&vp->v_uobj.memq)) { + if (vp->v_data) { vprint("cleaned vnode", vp); panic("cleaned vnode isn't"); } + s = splbio(); if (vp->v_numoutput) panic("Clean vnode has pending I/O's"); + splx(s); #endif vp->v_flag = 0; vp->v_socket = 0; @@ -472,10 +465,7 @@ getnewvnode(tag, mp, vops, vpp) *vpp = vp; vp->v_usecount = 1; vp->v_data = 0; - simple_lock_init(&vp->v_uobj.vmobjlock); - - vp->v_size = VSIZENOTSET; - + simple_lock_init(&vp->v_uvm.u_obj.vmobjlock); return (0); } @@ -679,10 +669,6 @@ vget(vp, flags, p) flags |= LK_INTERLOCK; } if (vp->v_flag & VXLOCK) { - if (flags & LK_NOWAIT) { - simple_unlock(&vp->v_interlock); - return (EBUSY); - } vp->v_flag |= VXWANT; simple_unlock(&vp->v_interlock); tsleep((caddr_t)vp, PINOD, "vget", 0); @@ -801,11 +787,6 @@ vput(vp) #endif vputonfreelist(vp); - if (vp->v_flag & VTEXT) { - uvmexp.vtextpages -= vp->v_uobj.uo_npages; - uvmexp.vnodepages += vp->v_uobj.uo_npages; - } - vp->v_flag &= ~VTEXT; simple_unlock(&vp->v_interlock); VOP_INACTIVE(vp, p); @@ -846,21 +827,18 @@ vrele(vp) #endif vputonfreelist(vp); - if (vp->v_flag & VTEXT) { - uvmexp.vtextpages -= vp->v_uobj.uo_npages; - uvmexp.vnodepages += vp->v_uobj.uo_npages; - } - vp->v_flag &= ~VTEXT; if (vn_lock(vp, LK_EXCLUSIVE|LK_INTERLOCK, p) == 0) VOP_INACTIVE(vp, p); } +void vhold __P((struct vnode *vp)); + /* * Page or buffer structure gets a reference. - * Must be called at splbio(); */ void -vhold(struct vnode *vp) +vhold(vp) + register struct vnode *vp; { /* @@ -880,34 +858,6 @@ vhold(struct vnode *vp) } /* - * Release a vhold reference. - * Must be called at splbio(); - */ -void -vholdrele(struct vnode *vp) -{ - simple_lock(&vp->v_interlock); -#ifdef DIAGNOSTIC - if (vp->v_holdcnt == 0) - panic("vholdrele: holdcnt"); -#endif - vp->v_holdcnt--; - - /* - * If it is on the holdlist and the hold count drops to - * zero, move it to the free list. - */ - if ((vp->v_bioflag & VBIOONFREELIST) && - vp->v_holdcnt == 0 && vp->v_usecount == 0) { - simple_lock(&vnode_free_list_slock); - TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist); - TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); - simple_unlock(&vnode_free_list_slock); - } - simple_unlock(&vp->v_interlock); -} - -/* * Remove any vnodes in the vnode table belonging to mount point mp. * * If MNT_NOFORCE is specified, there should not be any active ones, @@ -1059,12 +1009,6 @@ vclean(vp, flags, p) if (vp->v_flag & VXLOCK) panic("vclean: deadlock"); vp->v_flag |= VXLOCK; - if (vp->v_flag & VTEXT) { - uvmexp.vtextpages -= vp->v_uobj.uo_npages; - uvmexp.vnodepages += vp->v_uobj.uo_npages; - } - vp->v_flag &= ~VTEXT; - /* * Even if the count is zero, the VOP_INACTIVE routine may still * have the object locked while it cleans it out. The VOP_LOCK @@ -1075,7 +1019,11 @@ vclean(vp, flags, p) VOP_LOCK(vp, LK_DRAIN | LK_INTERLOCK, p); /* - * Clean out any cached data associated with the vnode. + * clean out any VM data associated with the vnode. + */ + uvm_vnp_terminate(vp); + /* + * Clean out any buffers associated with the vnode. */ if (flags & DOCLOSE) vinvalbuf(vp, V_SAVE, NOCRED, p, 0, 0); @@ -2020,22 +1968,9 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) struct proc *p; int slpflag, slptimeo; { - struct uvm_object *uobj = &vp->v_uobj; - struct buf *bp; + register struct buf *bp; struct buf *nbp, *blist; - int s, error, rv; - int flushflags = PGO_ALLPAGES|PGO_FREE|PGO_SYNCIO| - (flags & V_SAVE ? PGO_CLEANIT : 0); - - /* XXXUBC this doesn't look at flags or slp* */ - if (vp->v_type == VREG) { - simple_lock(&uobj->vmobjlock); - rv = (uobj->pgops->pgo_flush)(uobj, 0, 0, flushflags); - simple_unlock(&uobj->vmobjlock); - if (!rv) { - return EIO; - } - } + int s, error; if (flags & V_SAVE) { s = splbio(); @@ -2105,21 +2040,12 @@ loop: void vflushbuf(vp, sync) - struct vnode *vp; + register struct vnode *vp; int sync; { - struct uvm_object *uobj = &vp->v_uobj; - struct buf *bp, *nbp; + register struct buf *bp, *nbp; int s; - if (vp->v_type == VREG) { - int flags = PGO_CLEANIT|PGO_ALLPAGES| (sync ? PGO_SYNCIO : 0); - - simple_lock(&uobj->vmobjlock); - (uobj->pgops->pgo_flush)(uobj, 0, 0, flags); - simple_unlock(&uobj->vmobjlock); - } - loop: s = splbio(); for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) { @@ -2185,27 +2111,44 @@ bgetvp(vp, bp) * Manipulates vnode buffer queues. Must be called at splbio(). */ void -brelvp(struct buf *bp) +brelvp(bp) + register struct buf *bp; { struct vnode *vp; - if ((vp = bp->b_vp) == NULL) + if ((vp = bp->b_vp) == (struct vnode *) 0) panic("brelvp: NULL"); - /* * Delete from old vnode list, if on one. */ if (bp->b_vnbufs.le_next != NOLIST) bufremvn(bp); - if (TAILQ_EMPTY(&vp->v_uobj.memq) && - (vp->v_bioflag & VBIOONSYNCLIST) && + if ((vp->v_bioflag & VBIOONSYNCLIST) && LIST_FIRST(&vp->v_dirtyblkhd) == NULL) { vp->v_bioflag &= ~VBIOONSYNCLIST; LIST_REMOVE(vp, v_synclist); } - bp->b_vp = NULL; + bp->b_vp = (struct vnode *) 0; + + simple_lock(&vp->v_interlock); +#ifdef DIAGNOSTIC + if (vp->v_holdcnt == 0) + panic("brelvp: holdcnt"); +#endif + vp->v_holdcnt--; - vholdrele(vp); + /* + * If it is on the holdlist and the hold count drops to + * zero, move it to the free list. + */ + if ((vp->v_bioflag & VBIOONFREELIST) && + vp->v_holdcnt == 0 && vp->v_usecount == 0) { + simple_lock(&vnode_free_list_slock); + TAILQ_REMOVE(&vnode_hold_list, vp, v_freelist); + TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist); + simple_unlock(&vnode_free_list_slock); + } + simple_unlock(&vp->v_interlock); } /* @@ -2262,8 +2205,7 @@ reassignbuf(bp) */ if ((bp->b_flags & B_DELWRI) == 0) { listheadp = &vp->v_cleanblkhd; - if (TAILQ_EMPTY(&vp->v_uobj.memq) && - (vp->v_bioflag & VBIOONSYNCLIST) && + if ((vp->v_bioflag & VBIOONSYNCLIST) && LIST_FIRST(&vp->v_dirtyblkhd) == NULL) { vp->v_bioflag &= ~VBIOONSYNCLIST; LIST_REMOVE(vp, v_synclist); |