summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2005-03-13 12:18:25 +0000
committerjeff <jeff@FreeBSD.org>2005-03-13 12:18:25 +0000
commit0d9df2e12d6a83b8934322f557844cc0bb7bd488 (patch)
treeaa27ba510f7c723270e0278e561283b717a36c7b
parent5d7c91ddde246cd0d3f506a01bb53ba5fb41dd5d (diff)
downloadFreeBSD-src-0d9df2e12d6a83b8934322f557844cc0bb7bd488.zip
FreeBSD-src-0d9df2e12d6a83b8934322f557844cc0bb7bd488.tar.gz
- The VI_DOOMED flag now signals the end of a vnode's relationship with
the filesystem. Check that rather than VI_XLOCK. - VOP_INACTIVE should no longer drop the vnode lock. - The vnode lock is required around calls to vrecycle() and vgone(). Sponsored by: Isilon Systems, Inc.
-rw-r--r--sys/fs/fdescfs/fdesc_vnops.c1
-rw-r--r--sys/fs/fifofs/fifo_vnops.c4
-rw-r--r--sys/fs/hpfs/hpfs_vnops.c2
-rw-r--r--sys/fs/msdosfs/msdosfs_denode.c1
-rw-r--r--sys/fs/msdosfs/msdosfs_vfsops.c2
-rw-r--r--sys/fs/ntfs/ntfs_vnops.c2
-rw-r--r--sys/fs/nullfs/null_subr.c4
-rw-r--r--sys/fs/nullfs/null_vnops.c16
-rw-r--r--sys/fs/nwfs/nwfs_io.c2
-rw-r--r--sys/fs/nwfs/nwfs_node.c1
-rw-r--r--sys/fs/pseudofs/pseudofs_vncache.c4
-rw-r--r--sys/fs/smbfs/smbfs_io.c2
-rw-r--r--sys/fs/smbfs/smbfs_node.c3
-rw-r--r--sys/fs/smbfs/smbfs_vnops.c15
-rw-r--r--sys/fs/umapfs/umap_vnops.c1
-rw-r--r--sys/fs/unionfs/union_vnops.c3
16 files changed, 17 insertions, 46 deletions
diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
index c3d0ef6..6134426 100644
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -498,7 +498,6 @@ fdesc_inactive(ap)
* Clear out the v_type field to avoid
* nasty things happening in vgone().
*/
- VOP_UNLOCK(vp, 0, ap->a_td);
vp->v_type = VNON;
return (0);
}
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c
index fba7d10..36e7478 100644
--- a/sys/fs/fifofs/fifo_vnops.c
+++ b/sys/fs/fifofs/fifo_vnops.c
@@ -447,11 +447,8 @@ fifo_close(ap)
} */ *ap;
{
struct vnode *vp = ap->a_vp;
- struct thread *td = ap->a_td;
struct fifoinfo *fip = vp->v_fifoinfo;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
-
if (ap->a_fflag & FREAD) {
fip->fi_readers--;
if (fip->fi_readers == 0)
@@ -463,7 +460,6 @@ fifo_close(ap)
socantrcvmore(fip->fi_readsock);
}
fifo_cleanup(vp);
- VOP_UNLOCK(vp, 0, td);
return (0);
}
diff --git a/sys/fs/hpfs/hpfs_vnops.c b/sys/fs/hpfs/hpfs_vnops.c
index 78cf78a..ce6b965 100644
--- a/sys/fs/hpfs/hpfs_vnops.c
+++ b/sys/fs/hpfs/hpfs_vnops.c
@@ -578,12 +578,10 @@ hpfs_inactive(ap)
vprint("hpfs_inactive: pushing active", vp);
if (hp->h_flag & H_INVAL) {
- VOP_UNLOCK(vp,0,ap->a_td);
vrecycle(vp, ap->a_td);
return (0);
}
- VOP_UNLOCK(vp,0,ap->a_td);
return (0);
}
diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c
index 283b070..247b00f 100644
--- a/sys/fs/msdosfs/msdosfs_denode.c
+++ b/sys/fs/msdosfs/msdosfs_denode.c
@@ -695,7 +695,6 @@ msdosfs_inactive(ap)
deupdat(dep, 0);
out:
- VOP_UNLOCK(vp, 0, td);
/*
* If we are done with the denode, reclaim it
* so that it can be reused immediately.
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
index 727481a..5d1a194 100644
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c
@@ -872,7 +872,7 @@ msdosfs_sync(mp, waitfor, td)
loop:
MNT_VNODE_FOREACH(vp, mp, nvp) {
VI_LOCK(vp);
- if (vp->v_type == VNON || (vp->v_iflag & VI_XLOCK)) {
+ if (vp->v_type == VNON || (vp->v_iflag & VI_DOOMED)) {
VI_UNLOCK(vp);
continue;
}
diff --git a/sys/fs/ntfs/ntfs_vnops.c b/sys/fs/ntfs/ntfs_vnops.c
index 419eb6b..1c0a0bb 100644
--- a/sys/fs/ntfs/ntfs_vnops.c
+++ b/sys/fs/ntfs/ntfs_vnops.c
@@ -223,8 +223,6 @@ ntfs_inactive(ap)
if (ntfs_prtactive && vrefcnt(vp) != 0)
vprint("ntfs_inactive: pushing active", vp);
- VOP_UNLOCK(vp, 0, ap->a_td);
-
/* XXX since we don't support any filesystem changes
* right now, nothing more needs to be done
*/
diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c
index ac54c21..f6543b2 100644
--- a/sys/fs/nullfs/null_subr.c
+++ b/sys/fs/nullfs/null_subr.c
@@ -128,7 +128,7 @@ loop:
* recycling the nullfs vnode or another thread
* in vrele() waiting for the vnode lock.
*/
- if ((vp->v_iflag & VI_XLOCK) != 0) {
+ if ((vp->v_iflag & VI_DOOMED) != 0) {
VI_UNLOCK(vp);
continue;
}
@@ -177,7 +177,7 @@ loop:
* recycling the nullfs vnode or another thread
* in vrele() waiting for the vnode lock.
*/
- if ((ovp->v_iflag & VI_XLOCK) != 0) {
+ if ((ovp->v_iflag & VI_DOOMED) != 0) {
VI_UNLOCK(ovp);
continue;
}
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
index f02adbc5..bee46ee 100644
--- a/sys/fs/nullfs/null_vnops.c
+++ b/sys/fs/nullfs/null_vnops.c
@@ -537,6 +537,10 @@ null_lock(struct vop_lock_args *ap)
return (error);
}
+ if ((flags & LK_INTERLOCK) == 0) {
+ VI_LOCK(vp);
+ flags |= LK_INTERLOCK;
+ }
if (vp->v_vnlock != NULL) {
/*
* The lower level has exported a struct lock to us. Use
@@ -546,10 +550,6 @@ null_lock(struct vop_lock_args *ap)
* going away doesn't mean the struct lock below us is.
* LK_EXCLUSIVE is fine.
*/
- if ((flags & LK_INTERLOCK) == 0) {
- VI_LOCK(vp);
- flags |= LK_INTERLOCK;
- }
nn = VTONULL(vp);
if ((flags & LK_TYPE_MASK) == LK_DRAIN) {
NULLFSDEBUG("null_lock: avoiding LK_DRAIN\n");
@@ -558,7 +558,7 @@ null_lock(struct vop_lock_args *ap)
* pending locks to complete. Afterwards the
* lockmgr call might block, but no other threads
* will attempt to use this nullfs vnode due to the
- * VI_XLOCK flag.
+ * VI_DOOMED flag.
*/
while (nn->null_pending_locks > 0) {
nn->null_drain_wakeup = 1;
@@ -580,7 +580,7 @@ null_lock(struct vop_lock_args *ap)
* and another process might have initiated a recycle
* operation. When that happens, just back out.
*/
- if (error == 0 && (vp->v_iflag & VI_XLOCK) != 0 &&
+ if (error == 0 && (vp->v_iflag & VI_DOOMED) != 0 &&
td != vp->v_vxthread) {
lockmgr(vp->v_vnlock,
(flags & ~LK_TYPE_MASK) | LK_RELEASE,
@@ -598,9 +598,6 @@ null_lock(struct vop_lock_args *ap)
nn->null_drain_wakeup = 0;
wakeup(&nn->null_pending_locks);
}
- if (error == ENOENT && (vp->v_iflag & VI_XLOCK) != 0 &&
- vp->v_vxthread != curthread)
- vx_waitl(vp);
VI_UNLOCK(vp);
return error;
} else {
@@ -695,7 +692,6 @@ null_inactive(struct vop_inactive_args *ap)
struct thread *td = ap->a_td;
vp->v_object = NULL;
- VOP_UNLOCK(vp, 0, td);
/*
* If this is the last reference, then free up the vnode
diff --git a/sys/fs/nwfs/nwfs_io.c b/sys/fs/nwfs/nwfs_io.c
index 9aa26c3..0b69756 100644
--- a/sys/fs/nwfs/nwfs_io.c
+++ b/sys/fs/nwfs/nwfs_io.c
@@ -600,7 +600,7 @@ nwfs_vinvalbuf(vp, td)
/* struct nwmount *nmp = VTONWFS(vp);*/
int error = 0;
- if (vp->v_iflag & VI_XLOCK)
+ if (vp->v_iflag & VI_DOOMED)
return (0);
while (np->n_flag & NFLUSHINPROG) {
diff --git a/sys/fs/nwfs/nwfs_node.c b/sys/fs/nwfs/nwfs_node.c
index 026d74c..29ce5d3 100644
--- a/sys/fs/nwfs/nwfs_node.c
+++ b/sys/fs/nwfs/nwfs_node.c
@@ -297,7 +297,6 @@ nwfs_inactive(ap)
error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, td, cred);
np->opened = 0;
}
- VOP_UNLOCK(vp, 0, td);
if (np->n_flag & NSHOULDFREE) {
cache_purge(vp);
vgone(vp);
diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c
index 3914908..ddbdb34 100644
--- a/sys/fs/pseudofs/pseudofs_vncache.c
+++ b/sys/fs/pseudofs/pseudofs_vncache.c
@@ -248,7 +248,9 @@ pfs_exit(void *arg, struct proc *p)
if (pvd->pvd_pid == p->p_pid) {
vnp = pvd->pvd_vnode;
mtx_unlock(&pfs_vncache_mutex);
+ VOP_LOCK(vnp, LK_EXCLUSIVE, curthread);
vgone(vnp);
+ VOP_UNLOCK(vnp, 0, curthread);
mtx_lock(&pfs_vncache_mutex);
pvd = pfs_vncache;
} else {
@@ -278,7 +280,9 @@ pfs_disable(struct pfs_node *pn)
if (pvd->pvd_pn == pn) {
vnp = pvd->pvd_vnode;
mtx_unlock(&pfs_vncache_mutex);
+ VOP_LOCK(vnp, LK_EXCLUSIVE, curthread);
vgone(vnp);
+ VOP_UNLOCK(vnp, 0, curthread);
mtx_lock(&pfs_vncache_mutex);
pvd = pfs_vncache;
} else {
diff --git a/sys/fs/smbfs/smbfs_io.c b/sys/fs/smbfs/smbfs_io.c
index ef18709..a516194 100644
--- a/sys/fs/smbfs/smbfs_io.c
+++ b/sys/fs/smbfs/smbfs_io.c
@@ -672,7 +672,7 @@ smbfs_vinvalbuf(struct vnode *vp, struct thread *td)
struct smbnode *np = VTOSMB(vp);
int error = 0;
- if (vp->v_iflag & VI_XLOCK)
+ if (vp->v_iflag & VI_DOOMED)
return 0;
while (np->n_flag & NFLUSHINPROG) {
diff --git a/sys/fs/smbfs/smbfs_node.c b/sys/fs/smbfs/smbfs_node.c
index e3d2f3b..7ad977b 100644
--- a/sys/fs/smbfs/smbfs_node.c
+++ b/sys/fs/smbfs/smbfs_node.c
@@ -220,8 +220,8 @@ loop:
*/
if ((vp->v_type == VDIR && (np->n_dosattr & SMB_FA_DIR) == 0) ||
(vp->v_type == VREG && (np->n_dosattr & SMB_FA_DIR) != 0)) {
- vput(vp);
vgone(vp);
+ vput(vp);
break;
}
*vpp = vp;
@@ -377,7 +377,6 @@ smbfs_inactive(ap)
np->n_flag &= ~NOPEN;
smbfs_attr_cacheremove(vp);
}
- VOP_UNLOCK(vp, 0, td);
if (np->n_flag & NGONE)
vrecycle(vp, td);
return (0);
diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c
index 6125b89..9b27a52 100644
--- a/sys/fs/smbfs/smbfs_vnops.c
+++ b/sys/fs/smbfs/smbfs_vnops.c
@@ -220,10 +220,6 @@ smbfs_open(ap)
return error;
}
-/*
- * XXX: VOP_CLOSE() usually called without lock held which is suck. Here we
- * do some heruistic to determine if vnode should be locked.
- */
static int
smbfs_close(ap)
struct vop_close_args /* {
@@ -238,22 +234,13 @@ smbfs_close(ap)
struct thread *td = ap->a_td;
struct smbnode *np = VTOSMB(vp);
struct smb_cred scred;
- int dolock;
- VI_LOCK(vp);
- dolock = (vp->v_iflag & VI_XLOCK) == 0;
- if (dolock)
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_INTERLOCK, td);
- else
- VI_UNLOCK(vp);
if (vp->v_type == VDIR && (np->n_flag & NOPEN) != 0 &&
np->n_dirseq != NULL) {
smb_makescred(&scred, td, ap->a_cred);
smbfs_findclose(np->n_dirseq, &scred);
np->n_dirseq = NULL;
}
- if (dolock)
- VOP_UNLOCK(vp, 0, td);
return 0;
}
@@ -1187,9 +1174,9 @@ smbfs_lookup(ap)
return (0);
}
cache_purge(vp);
- vput(vp);
if (killit)
vgone(vp);
+ vput(vp);
if (lockparent && dvp != vp && islastcn)
VOP_UNLOCK(dvp, 0, td);
}
diff --git a/sys/fs/umapfs/umap_vnops.c b/sys/fs/umapfs/umap_vnops.c
index 7ce5b26..92a3bc4 100644
--- a/sys/fs/umapfs/umap_vnops.c
+++ b/sys/fs/umapfs/umap_vnops.c
@@ -411,7 +411,6 @@ umap_inactive(ap)
*
*/
VOP_INACTIVE(lowervp, ap->a_td);
- VOP_UNLOCK(ap->a_vp, 0, ap->a_td);
return (0);
}
diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c
index 7e98623..7aef07c 100644
--- a/sys/fs/unionfs/union_vnops.c
+++ b/sys/fs/unionfs/union_vnops.c
@@ -1650,7 +1650,6 @@ union_inactive(ap)
} */ *ap;
{
struct vnode *vp = ap->a_vp;
- struct thread *td = ap->a_td;
struct union_node *un = VTOUNION(vp);
/*
@@ -1671,8 +1670,6 @@ union_inactive(ap)
}
#endif
- VOP_UNLOCK(vp, 0, td);
-
if ((un->un_flags & UN_CACHED) == 0)
vgone(vp);
OpenPOWER on IntegriCloud