summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c40
-rw-r--r--sys/fs/unionfs/union_subr.c7
-rw-r--r--sys/fs/unionfs/union_vnops.c145
-rw-r--r--sys/gnu/ext2fs/ext2_vnops.c35
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vnops.c35
-rw-r--r--sys/kern/uipc_usrreq.c6
-rw-r--r--sys/kern/vfs_extattr.c40
-rw-r--r--sys/kern/vfs_syscalls.c40
-rw-r--r--sys/kern/vfs_vnops.c8
-rw-r--r--sys/kern/vnode_if.src40
-rw-r--r--sys/miscfs/devfs/devfs_vnops.c37
-rw-r--r--sys/miscfs/union/union_subr.c7
-rw-r--r--sys/miscfs/union/union_vnops.c145
-rw-r--r--sys/msdosfs/msdosfs_vnops.c40
-rw-r--r--sys/netinet/mlf_ipl.c7
-rw-r--r--sys/nfs/nfs_serv.c37
-rw-r--r--sys/nfs/nfs_vnops.c22
-rw-r--r--sys/nfsclient/nfs_vnops.c22
-rw-r--r--sys/nfsserver/nfs_serv.c37
-rw-r--r--sys/ufs/ufs/ufs_vnops.c27
20 files changed, 360 insertions, 417 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 4185114..555b271 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $Id: msdosfs_vnops.c,v 1.66 1998/03/20 02:33:42 kato Exp $ */
+/* $Id: msdosfs_vnops.c,v 1.67 1998/03/26 20:52:58 phk Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */
/*-
@@ -187,13 +187,11 @@ msdosfs_create(ap)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
*ap->a_vpp = DETOV(dep);
return (0);
bad:
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
return (error);
}
@@ -218,7 +216,6 @@ msdosfs_mknod(ap)
default:
zfree(namei_zone, ap->a_cnp->cn_pnbuf);
- vput(ap->a_dvp);
return (EINVAL);
}
/* NOTREACHED */
@@ -872,9 +869,9 @@ msdosfs_remove(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error;
struct denode *dep = VTODE(ap->a_vp);
struct denode *ddep = VTODE(ap->a_dvp);
+ int error;
if (ap->a_vp->v_type == VDIR)
error = EPERM;
@@ -883,12 +880,6 @@ msdosfs_remove(ap)
#ifdef MSDOSFS_DEBUG
printf("msdosfs_remove(), dep %p, v_usecount %d\n", dep, ap->a_vp->v_usecount);
#endif
- if (ddep == dep)
- vrele(ap->a_vp);
- else
- vput(ap->a_vp); /* causes msdosfs_inactive() to be called
- * via vrele() */
- vput(ap->a_dvp);
return (error);
}
@@ -906,8 +897,7 @@ msdosfs_link(ap)
} */ *ap;
{
VOP_ABORTOP(ap->a_tdvp, ap->a_cnp);
- vput(ap->a_tdvp);
- return EOPNOTSUPP;
+ return (EOPNOTSUPP);
}
/*
@@ -1324,15 +1314,15 @@ msdosfs_mkdir(ap)
} */ *ap;
{
struct componentname *cnp = ap->a_cnp;
- struct denode ndirent;
struct denode *dep;
struct denode *pdep = VTODE(ap->a_dvp);
- int error;
- int bn;
- u_long newcluster, pcl;
struct direntry *denp;
struct msdosfsmount *pmp = pdep->de_pmp;
struct buf *bp;
+ u_long newcluster, pcl;
+ int bn;
+ int error;
+ struct denode ndirent;
struct timespec ts;
/*
@@ -1419,7 +1409,6 @@ msdosfs_mkdir(ap)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
*ap->a_vpp = DETOV(dep);
return (0);
@@ -1427,7 +1416,6 @@ bad:
clusterfree(pmp, newcluster, NULL);
bad2:
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
return (error);
}
@@ -1443,6 +1431,7 @@ msdosfs_rmdir(ap)
register struct vnode *dvp = ap->a_dvp;
register struct componentname *cnp = ap->a_cnp;
register struct denode *ip, *dp;
+ struct proc *p = cnp->cn_proc;
int error;
ip = VTODE(vp);
@@ -1474,20 +1463,18 @@ msdosfs_rmdir(ap)
/*
* This is where we decrement the link count in the parent
* directory. Since dos filesystems don't do this we just purge
- * the name cache and let go of the parent directory denode.
+ * the name cache.
*/
cache_purge(dvp);
- vput(dvp);
- dvp = NULL;
+ VOP_UNLOCK(dvp, 0, p);
/*
* Truncate the directory that is being deleted.
*/
- error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, cnp->cn_proc);
+ error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, p);
cache_purge(vp);
+
+ vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
out:
- if (dvp)
- vput(dvp);
- vput(vp);
return (error);
}
@@ -1506,7 +1493,6 @@ msdosfs_symlink(ap)
{
zfree(namei_zone, ap->a_cnp->cn_pnbuf);
/* VOP_ABORTOP(ap->a_dvp, ap->a_cnp); ??? */
- vput(ap->a_dvp);
return (EOPNOTSUPP);
}
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index 879b0d0..7173734 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)union_subr.c 8.20 (Berkeley) 5/20/95
- * $Id: union_subr.c,v 1.28 1998/02/10 03:32:05 kato Exp $
+ * $Id: union_subr.c,v 1.29 1998/02/26 03:23:54 kato Exp $
*/
#include <sys/param.h>
@@ -830,6 +830,7 @@ union_mkshadow(um, dvp, cnp, vpp)
VOP_LEASE(dvp, p, cn.cn_cred, LEASE_WRITE);
error = VOP_MKDIR(dvp, vpp, &cn, &va);
+ vput(dvp);
return (error);
}
@@ -955,7 +956,9 @@ union_vn_create(vpp, un, p)
vap->va_type = VREG;
vap->va_mode = cmode;
VOP_LEASE(un->un_dirvp, p, cred, LEASE_WRITE);
- if (error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap))
+ error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap);
+ vput(un->un_dirvp);
+ if (error)
return (error);
error = VOP_OPEN(vp, fmode, cred, p);
diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c
index e9a7a76..f1c6d78 100644
--- a/sys/fs/unionfs/union_vnops.c
+++ b/sys/fs/unionfs/union_vnops.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)union_vnops.c 8.32 (Berkeley) 6/23/95
- * $Id: union_vnops.c,v 1.55 1998/02/26 03:23:56 kato Exp $
+ * $Id: union_vnops.c,v 1.56 1998/03/17 08:47:50 kato Exp $
*/
#include <sys/param.h>
@@ -490,34 +490,36 @@ union_create(ap)
struct vattr *a_vap;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
struct mount *mp;
+ int error;
- FIXUP(un, p);
+ FIXUP(dun, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
- mp = ap->a_dvp->v_mount;
- vput(ap->a_dvp);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_CREATE(dvp, &vp, cnp, ap->a_vap);
- if (error)
+ if (error) {
+ dun->un_flags |= UN_ULOCK;
return (error);
+ }
+ mp = ap->a_dvp->v_mount;
+ VOP_UNLOCK(dvp, 0, p);
error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP, cnp, vp,
NULLVP, 1);
if (error)
vput(vp);
+ vn_lock(ap->a_dvp, LK_EXCLUSIVE| LK_RETRY, p);
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
@@ -549,36 +551,40 @@ union_mknod(ap)
struct vattr *a_vap;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
struct mount *mp;
+ int error;
- FIXUP(un, p);
+ FIXUP(dun, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
- mp = ap->a_dvp->v_mount;
- vput(ap->a_dvp);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_MKNOD(dvp, &vp, cnp, ap->a_vap);
- if (error)
+ if (error) {
+ dun->un_flags |= UN_ULOCK;
return (error);
+ }
if (vp != NULLVP) {
+ mp = ap->a_dvp->v_mount;
+ VOP_UNLOCK(dvp, 0, p);
error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
cnp, vp, NULLVP, 1);
if (error)
vput(vp);
+ vn_lock(ap->a_dvp, LK_EXCLUSIVE| LK_RETRY, p);
+ } else {
+ dun->un_flags |= UN_ULOCK;
}
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
@@ -1055,11 +1061,11 @@ union_remove(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error;
struct union_node *dun = VTOUNION(ap->a_dvp);
struct union_node *un = VTOUNION(ap->a_vp);
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
+ int error;
if (dun->un_uppervp == NULLVP)
panic("union remove: null upper vnode");
@@ -1069,15 +1075,13 @@ union_remove(ap)
struct vnode *vp = un->un_uppervp;
FIXUP(dun, p);
- VREF(dvp);
dun->un_flags |= UN_KLOCK;
- vput(ap->a_dvp);
+ VOP_UNLOCK(ap->a_dvp, 0, p);
FIXUP(un, p);
- VREF(vp);
un->un_flags |= UN_KLOCK;
- vput(ap->a_vp);
+ VOP_UNLOCK(ap->a_vp, 0, p);
- if (union_dowhiteout(un, cnp->cn_cred, cnp->cn_proc))
+ if (union_dowhiteout(un, cnp->cn_cred, p))
cnp->cn_flags |= DOWHITEOUT;
error = VOP_REMOVE(dvp, vp, cnp);
#if 0
@@ -1085,13 +1089,13 @@ union_remove(ap)
if (!error)
union_removed_upper(un);
#endif
+ dun->un_flags |= UN_ULOCK;
+ un->un_flags |= UN_ULOCK;
} else {
FIXUP(dun, p);
error = union_mkwhiteout(
MOUNTTOUNIONMOUNT(UNIONTOV(dun)->v_mount),
dun->un_uppervp, ap->a_cnp, un->un_path);
- vput(ap->a_dvp);
- vput(ap->a_vp);
}
return (error);
@@ -1105,14 +1109,13 @@ union_link(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error = 0;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
- struct union_node *un;
+ struct union_node *dun = VTOUNION(ap->a_tdvp);
struct vnode *vp;
struct vnode *tdvp;
+ int error = 0;
- un = VTOUNION(ap->a_tdvp);
if (ap->a_tdvp->v_op != ap->a_vp->v_op) {
vp = ap->a_vp;
@@ -1120,36 +1123,37 @@ union_link(ap)
struct union_node *tun = VTOUNION(ap->a_vp);
if (tun->un_uppervp == NULLVP) {
vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (un->un_uppervp == tun->un_dirvp) {
- un->un_flags &= ~UN_ULOCK;
- VOP_UNLOCK(un->un_uppervp, 0, p);
+ if (dun->un_uppervp == tun->un_dirvp) {
+ dun->un_flags &= ~UN_ULOCK;
+ VOP_UNLOCK(dun->un_uppervp, 0, p);
}
error = union_copyup(tun, 1, cnp->cn_cred, p);
- if (un->un_uppervp == tun->un_dirvp) {
- vn_lock(un->un_uppervp,
+ if (dun->un_uppervp == tun->un_dirvp) {
+ vn_lock(dun->un_uppervp,
LK_EXCLUSIVE | LK_RETRY, p);
- un->un_flags |= UN_ULOCK;
+ dun->un_flags |= UN_ULOCK;
}
VOP_UNLOCK(ap->a_vp, 0, p);
}
vp = tun->un_uppervp;
}
- tdvp = un->un_uppervp;
+ tdvp = dun->un_uppervp;
if (tdvp == NULLVP)
error = EROFS;
- if (error) {
- vput(ap->a_tdvp);
+ if (error)
return (error);
- }
- FIXUP(un, p);
- VREF(tdvp);
- un->un_flags |= UN_KLOCK;
- vput(ap->a_tdvp);
+ FIXUP(dun, p);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_tdvp, 0, p);
+
+ error = VOP_LINK(tdvp, vp, cnp);
- return (VOP_LINK(tdvp, vp, cnp));
+ dun->un_flags |= UN_ULOCK;
+
+ return (error);
}
static int
@@ -1255,34 +1259,34 @@ union_mkdir(ap)
struct vattr *a_vap;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
+ int error;
- FIXUP(un, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
+ FIXUP(dun, p);
+ dun->un_flags |= UN_KLOCK;
VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_MKDIR(dvp, &vp, cnp, ap->a_vap);
if (error) {
- vrele(ap->a_dvp);
+ dun->un_flags |= UN_ULOCK;
return (error);
}
+ VOP_UNLOCK(dvp, 0, p);
error = union_allocvp(ap->a_vpp, ap->a_dvp->v_mount, ap->a_dvp,
NULLVP, cnp, vp, NULLVP, 1);
- vrele(ap->a_dvp);
if (error)
vput(vp);
+ vn_lock(ap->a_dvp, LK_EXCLUSIVE| LK_RETRY, p);
+
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
@@ -1294,11 +1298,11 @@ union_rmdir(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error;
struct union_node *dun = VTOUNION(ap->a_dvp);
struct union_node *un = VTOUNION(ap->a_vp);
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
+ int error;
if (dun->un_uppervp == NULLVP)
panic("union rmdir: null upper vnode");
@@ -1308,15 +1312,13 @@ union_rmdir(ap)
struct vnode *vp = un->un_uppervp;
FIXUP(dun, p);
- VREF(dvp);
dun->un_flags |= UN_KLOCK;
- vput(ap->a_dvp);
+ VOP_UNLOCK(ap->a_dvp, 0, p);
FIXUP(un, p);
- VREF(vp);
un->un_flags |= UN_KLOCK;
- vput(ap->a_vp);
+ VOP_UNLOCK(ap->a_vp, 0, p);
- if (union_dowhiteout(un, cnp->cn_cred, cnp->cn_proc))
+ if (union_dowhiteout(un, cnp->cn_cred, p))
cnp->cn_flags |= DOWHITEOUT;
error = VOP_RMDIR(dvp, vp, ap->a_cnp);
#if 0
@@ -1324,13 +1326,13 @@ union_rmdir(ap)
if (!error)
union_removed_upper(un);
#endif
+ dun->un_flags |= UN_ULOCK;
+ un->un_flags |= UN_ULOCK;
} else {
FIXUP(dun, p);
error = union_mkwhiteout(
MOUNTTOUNIONMOUNT(UNIONTOV(dun)->v_mount),
dun->un_uppervp, ap->a_cnp, un->un_path);
- vput(ap->a_dvp);
- vput(ap->a_vp);
}
return (error);
@@ -1346,25 +1348,24 @@ union_symlink(ap)
char *a_target;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
+ int error;
- FIXUP(un, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
- vput(ap->a_dvp);
+ FIXUP(dun, p);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_SYMLINK(dvp, &vp, cnp, ap->a_vap, ap->a_target);
+ dun->un_flags |= UN_ULOCK;
*ap->a_vpp = NULLVP;
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c
index f533012..21068e4 100644
--- a/sys/gnu/ext2fs/ext2_vnops.c
+++ b/sys/gnu/ext2fs/ext2_vnops.c
@@ -301,11 +301,6 @@ ext2_remove(ap)
ip->i_flag |= IN_CHANGE;
}
out:
- if (dvp == vp)
- vrele(vp);
- else
- vput(vp);
- vput(dvp);
return (error);
}
@@ -367,7 +362,6 @@ out1:
if (tdvp != vp)
VOP_UNLOCK(vp, 0, p);
out2:
- vput(tdvp);
return (error);
}
@@ -480,7 +474,15 @@ abortit:
#endif
return (ENOENT);
}
- return (VOP_REMOVE(fdvp, fvp, fcnp));
+ error = VOP_REMOVE(fdvp, fvp, fcnp);
+ /* XXX - temporarily preserve previous behavior */
+ if (fdvp == fvp)
+ vrele(fdvp);
+ else
+ vput(fdvp);
+ if (fvp != NULLVP)
+ vput(fvp);
+ return (error);
}
if (error = vn_lock(fvp, LK_EXCLUSIVE, p))
goto abortit;
@@ -873,7 +875,6 @@ ext2_mkdir(ap)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, dmode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -886,7 +887,6 @@ ext2_mkdir(ap)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, dmode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -957,7 +957,6 @@ bad:
*ap->a_vpp = tvp;
out:
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
#undef DIRBLKSIZ
#define DIRBLKSIZ DEV_BSIZE
@@ -977,6 +976,7 @@ ext2_rmdir(ap)
struct vnode *vp = ap->a_vp;
struct vnode *dvp = ap->a_dvp;
struct componentname *cnp = ap->a_cnp;
+ struct proc *p = cnp->cn_proc;
struct inode *ip, *dp;
int error;
@@ -1011,8 +1011,7 @@ ext2_rmdir(ap)
dp->i_nlink--;
dp->i_flag |= IN_CHANGE;
cache_purge(dvp);
- vput(dvp);
- dvp = NULL;
+ VOP_UNLOCK(dvp, 0, p);
/*
* Truncate inode. The only stuff left
* in the directory is "." and "..". The
@@ -1025,13 +1024,10 @@ ext2_rmdir(ap)
* worry about them later.
*/
ip->i_nlink -= 2;
- error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred,
- cnp->cn_proc);
+ error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, p);
cache_purge(ITOV(ip));
+ vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
out:
- if (dvp)
- vput(dvp);
- vput(vp);
return (error);
}
@@ -1098,7 +1094,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
error = UFS_VALLOC(dvp, mode, cnp->cn_cred, &tvp);
if (error) {
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
}
ip = VTOI(tvp);
@@ -1146,7 +1141,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, mode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -1159,7 +1153,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, mode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -1188,7 +1181,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
if ((cnp->cn_flags & SAVESTART) == 0)
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
*vpp = tvp;
return (0);
@@ -1198,7 +1190,6 @@ bad:
* or the directory so must deallocate the inode.
*/
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
ip->i_nlink = 0;
ip->i_flag |= IN_CHANGE;
vput(tvp);
diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c
index f533012..21068e4 100644
--- a/sys/gnu/fs/ext2fs/ext2_vnops.c
+++ b/sys/gnu/fs/ext2fs/ext2_vnops.c
@@ -301,11 +301,6 @@ ext2_remove(ap)
ip->i_flag |= IN_CHANGE;
}
out:
- if (dvp == vp)
- vrele(vp);
- else
- vput(vp);
- vput(dvp);
return (error);
}
@@ -367,7 +362,6 @@ out1:
if (tdvp != vp)
VOP_UNLOCK(vp, 0, p);
out2:
- vput(tdvp);
return (error);
}
@@ -480,7 +474,15 @@ abortit:
#endif
return (ENOENT);
}
- return (VOP_REMOVE(fdvp, fvp, fcnp));
+ error = VOP_REMOVE(fdvp, fvp, fcnp);
+ /* XXX - temporarily preserve previous behavior */
+ if (fdvp == fvp)
+ vrele(fdvp);
+ else
+ vput(fdvp);
+ if (fvp != NULLVP)
+ vput(fvp);
+ return (error);
}
if (error = vn_lock(fvp, LK_EXCLUSIVE, p))
goto abortit;
@@ -873,7 +875,6 @@ ext2_mkdir(ap)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, dmode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -886,7 +887,6 @@ ext2_mkdir(ap)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, dmode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -957,7 +957,6 @@ bad:
*ap->a_vpp = tvp;
out:
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
#undef DIRBLKSIZ
#define DIRBLKSIZ DEV_BSIZE
@@ -977,6 +976,7 @@ ext2_rmdir(ap)
struct vnode *vp = ap->a_vp;
struct vnode *dvp = ap->a_dvp;
struct componentname *cnp = ap->a_cnp;
+ struct proc *p = cnp->cn_proc;
struct inode *ip, *dp;
int error;
@@ -1011,8 +1011,7 @@ ext2_rmdir(ap)
dp->i_nlink--;
dp->i_flag |= IN_CHANGE;
cache_purge(dvp);
- vput(dvp);
- dvp = NULL;
+ VOP_UNLOCK(dvp, 0, p);
/*
* Truncate inode. The only stuff left
* in the directory is "." and "..". The
@@ -1025,13 +1024,10 @@ ext2_rmdir(ap)
* worry about them later.
*/
ip->i_nlink -= 2;
- error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred,
- cnp->cn_proc);
+ error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, p);
cache_purge(ITOV(ip));
+ vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
out:
- if (dvp)
- vput(dvp);
- vput(vp);
return (error);
}
@@ -1098,7 +1094,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
error = UFS_VALLOC(dvp, mode, cnp->cn_cred, &tvp);
if (error) {
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
}
ip = VTOI(tvp);
@@ -1146,7 +1141,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, mode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -1159,7 +1153,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, mode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -1188,7 +1181,6 @@ ext2_makeinode(mode, dvp, vpp, cnp)
if ((cnp->cn_flags & SAVESTART) == 0)
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
*vpp = tvp;
return (0);
@@ -1198,7 +1190,6 @@ bad:
* or the directory so must deallocate the inode.
*/
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
ip->i_nlink = 0;
ip->i_flag |= IN_CHANGE;
vput(tvp);
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 8ca43f5..b225c7c 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
- * $Id: uipc_usrreq.c,v 1.32 1998/02/06 12:13:28 eivind Exp $
+ * $Id: uipc_usrreq.c,v 1.33 1998/04/17 22:36:50 des Exp $
*/
#include <sys/param.h>
@@ -549,7 +549,9 @@ unp_bind(unp, nam, p)
vattr.va_type = VSOCK;
vattr.va_mode = (ACCESSPERMS & ~p->p_fd->fd_cmask);
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr))
+ error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
+ if (error)
return (error);
vp = nd.ni_vp;
vp->v_socket = unp->unp_socket;
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index e96b515..7fd30cc 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $Id: vfs_syscalls.c,v 1.97 1998/04/08 18:31:57 wosch Exp $
+ * $Id: vfs_syscalls.c,v 1.99 1998/04/19 22:20:32 des Exp $
*/
/* For 4.3 integer FS ID compatibility */
@@ -1042,6 +1042,7 @@ mknod(p, uap)
} else {
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
&nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
}
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -1095,7 +1096,9 @@ mkfifo(p, uap)
vattr.va_type = VFIFO;
vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
+ return (error);
}
/*
@@ -1132,10 +1135,6 @@ link(p, uap)
if (!error) {
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
if (nd.ni_vp)
vrele(nd.ni_vp);
error = EEXIST;
@@ -1145,6 +1144,10 @@ link(p, uap)
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
}
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
}
}
vrele(vp);
@@ -1196,6 +1199,7 @@ symlink(p, uap)
vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path);
+ vput(nd.ni_dvp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "symlink");
ASSERT_VOP_UNLOCKED(nd.ni_vp, "symlink");
out:
@@ -1287,13 +1291,13 @@ unlink(p, uap)
error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- if (vp != NULLVP)
- vput(vp);
}
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP)
+ vput(vp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "unlink");
ASSERT_VOP_UNLOCKED(nd.ni_vp, "unlink");
return (error);
@@ -2334,6 +2338,7 @@ mkdir(p, uap)
vattr.va_mode = (SCARG(uap, mode) & ACCESSPERMS) &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
if (!error)
vput(nd.ni_vp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "mkdir");
@@ -2389,12 +2394,13 @@ out:
error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(vp);
}
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP)
+ vput(vp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "rmdir");
ASSERT_VOP_UNLOCKED(nd.ni_vp, "rmdir");
return (error);
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index e96b515..7fd30cc 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $Id: vfs_syscalls.c,v 1.97 1998/04/08 18:31:57 wosch Exp $
+ * $Id: vfs_syscalls.c,v 1.99 1998/04/19 22:20:32 des Exp $
*/
/* For 4.3 integer FS ID compatibility */
@@ -1042,6 +1042,7 @@ mknod(p, uap)
} else {
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
&nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
}
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -1095,7 +1096,9 @@ mkfifo(p, uap)
vattr.va_type = VFIFO;
vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
+ return (error);
}
/*
@@ -1132,10 +1135,6 @@ link(p, uap)
if (!error) {
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
if (nd.ni_vp)
vrele(nd.ni_vp);
error = EEXIST;
@@ -1145,6 +1144,10 @@ link(p, uap)
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
}
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
}
}
vrele(vp);
@@ -1196,6 +1199,7 @@ symlink(p, uap)
vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path);
+ vput(nd.ni_dvp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "symlink");
ASSERT_VOP_UNLOCKED(nd.ni_vp, "symlink");
out:
@@ -1287,13 +1291,13 @@ unlink(p, uap)
error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- if (vp != NULLVP)
- vput(vp);
}
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP)
+ vput(vp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "unlink");
ASSERT_VOP_UNLOCKED(nd.ni_vp, "unlink");
return (error);
@@ -2334,6 +2338,7 @@ mkdir(p, uap)
vattr.va_mode = (SCARG(uap, mode) & ACCESSPERMS) &~ p->p_fd->fd_cmask;
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
if (!error)
vput(nd.ni_vp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "mkdir");
@@ -2389,12 +2394,13 @@ out:
error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(vp);
}
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP)
+ vput(vp);
ASSERT_VOP_UNLOCKED(nd.ni_dvp, "rmdir");
ASSERT_VOP_UNLOCKED(nd.ni_vp, "rmdir");
return (error);
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 31d4f2c..efee10e 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
- * $Id: vfs_vnops.c,v 1.55 1998/04/08 18:31:58 wosch Exp $
+ * $Id: vfs_vnops.c,v 1.56 1998/04/10 00:09:04 alex Exp $
*/
#include <sys/param.h>
@@ -95,8 +95,10 @@ vn_open(ndp, fmode, cmode)
if (fmode & O_EXCL)
vap->va_vaflags |= VA_EXCLUSIVE;
VOP_LEASE(ndp->ni_dvp, p, cred, LEASE_WRITE);
- if (error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
- &ndp->ni_cnd, vap))
+ error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
+ &ndp->ni_cnd, vap);
+ vput(ndp->ni_dvp);
+ if (error)
return (error);
ASSERT_VOP_UNLOCKED(ndp->ni_dvp, "create");
ASSERT_VOP_LOCKED(ndp->ni_vp, "create");
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
index 922e060..c97d2ad 100644
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -31,7 +31,7 @@
# SUCH DAMAGE.
#
# @(#)vnode_if.src 8.12 (Berkeley) 5/14/95
-# $Id: vnode_if.src,v 1.15 1997/10/16 20:32:23 phk Exp $
+# $Id: vnode_if.src,v 1.16 1998/03/08 09:57:26 julian Exp $
#
#
@@ -77,11 +77,11 @@ vop_cachedlookup {
};
#
-#% create dvp L U U
+#% create dvp L L L
#% create vpp - L -
#
vop_create {
- IN WILLRELE struct vnode *dvp;
+ IN struct vnode *dvp;
OUT struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -93,17 +93,17 @@ vop_create {
#% whiteout flag - - -
#
vop_whiteout {
- IN WILLRELE struct vnode *dvp;
+ IN struct vnode *dvp;
IN struct componentname *cnp;
IN int flags;
};
#
-#% mknod dvp L U U
+#% mknod dvp L L L
#% mknod vpp - X -
#
vop_mknod {
- IN WILLRELE struct vnode *dvp;
+ IN struct vnode *dvp;
OUT WILLRELE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -240,21 +240,21 @@ vop_fsync {
};
#
-#% remove dvp L U U
-#% remove vp L U U
+#% remove dvp L L L
+#% remove vp L L L
#
vop_remove {
- IN WILLRELE struct vnode *dvp;
- IN WILLRELE struct vnode *vp;
+ IN struct vnode *dvp;
+ IN struct vnode *vp;
IN struct componentname *cnp;
};
#
+#% link tdvp L L L
#% link vp U U U
-#% link tdvp L U U
#
vop_link {
- IN WILLRELE struct vnode *tdvp;
+ IN struct vnode *tdvp;
IN struct vnode *vp;
IN struct componentname *cnp;
};
@@ -275,28 +275,28 @@ vop_rename {
};
#
-#% mkdir dvp L U U
+#% mkdir dvp L L L
#% mkdir vpp - L -
#
vop_mkdir {
- IN WILLRELE struct vnode *dvp;
+ IN struct vnode *dvp;
OUT struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
};
#
-#% rmdir dvp L U U
-#% rmdir vp L U U
+#% rmdir dvp L L L
+#% rmdir vp L L L
#
vop_rmdir {
- IN WILLRELE struct vnode *dvp;
- IN WILLRELE struct vnode *vp;
+ IN struct vnode *dvp;
+ IN struct vnode *vp;
IN struct componentname *cnp;
};
#
-#% symlink dvp L U U
+#% symlink dvp L L L
#% symlink vpp - U -
#
# XXX - note that the return vnode has already been VRELE'ed
@@ -304,7 +304,7 @@ vop_rmdir {
# possibly with a further namei.
#
vop_symlink {
- IN WILLRELE struct vnode *dvp;
+ IN struct vnode *dvp;
OUT WILLRELE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
diff --git a/sys/miscfs/devfs/devfs_vnops.c b/sys/miscfs/devfs/devfs_vnops.c
index 6c9bae7..c35d63f 100644
--- a/sys/miscfs/devfs/devfs_vnops.c
+++ b/sys/miscfs/devfs/devfs_vnops.c
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: devfs_vnops.c,v 1.53 1998/03/26 20:52:12 phk Exp $
+ * $Id: devfs_vnops.c,v 1.54 1998/04/19 23:32:17 julian Exp $
*/
@@ -320,7 +320,6 @@ devfs_create(struct vop_mknod_args *ap)
} */
{
DBPRINT(("create\n"));
- vput(ap->a_dvp);
return EINVAL;
}
@@ -773,18 +772,12 @@ DBPRINT(("remove\n"));
* are the end of the path. Get pointers to all our
* devfs structures.
*/
- if ( error = devfs_vntodn(dvp,&tdp)) {
+ if (error = devfs_vntodn(dvp, &tdp)) {
abortit:
VOP_ABORTOP(dvp, cnp);
- if (dvp == vp) /* eh? */
- vrele(dvp);
- else
- vput(dvp);
- if (vp)
- vput(vp);
return (error);
}
- if ( error = devfs_vntodn(vp,&tp)) goto abortit;
+ if (error = devfs_vntodn(vp, &tp)) goto abortit;
/*
* Assuming we are atomic, dev_lookup left this for us
*/
@@ -846,8 +839,6 @@ abortit:
}
dev_free_name(tnp);
tp = NULL;
- vput(vp);
- vput(dvp);
return (error);
}
@@ -915,7 +906,6 @@ abortit:
fp,
&tnp);
out:
- vput(tdvp);
return (error);
}
@@ -1186,9 +1176,7 @@ devfs_rmdir(struct vop_rmdir_args *ap)
} */
{
DBPRINT(("rmdir\n"));
- vput(ap->a_dvp);
- vput(ap->a_vp);
- return 0;
+ return (0);
}
#endif
@@ -1202,30 +1190,27 @@ devfs_symlink(struct vop_symlink_args *ap)
char *a_target;
} */
{
- int err;
+ struct vnode *vp;
+ int error;
dn_p dnp;
union typeinfo by;
devnm_p nm_p;
- struct vnode *vp;
DBPRINT(("symlink\n"));
- if(err = devfs_vntodn(ap->a_dvp,&dnp)) {
- vput(ap->a_dvp);
- return err;
+ if(error = devfs_vntodn(ap->a_dvp, &dnp)) {
+ return (error);
}
by.Slnk.name = ap->a_target;
by.Slnk.namelen = strlen(ap->a_target);
- dev_add_entry( ap->a_cnp->cn_nameptr, dnp, DEV_SLNK, &by,
+ dev_add_entry(ap->a_cnp->cn_nameptr, dnp, DEV_SLNK, &by,
NULL, NULL, &nm_p);
- if(err = devfs_dntovn(nm_p->dnp,&vp) ) {
- vput(ap->a_dvp);
- return err;
+ if(error = devfs_dntovn(nm_p->dnp, &vp)) {
+ return (error);
}
VOP_SETATTR(vp, ap->a_vap, ap->a_cnp->cn_cred, ap->a_cnp->cn_proc);
*ap->a_vpp = NULL;
vput(vp);
- vput(ap->a_dvp);
return 0;
}
diff --git a/sys/miscfs/union/union_subr.c b/sys/miscfs/union/union_subr.c
index 879b0d0..7173734 100644
--- a/sys/miscfs/union/union_subr.c
+++ b/sys/miscfs/union/union_subr.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)union_subr.c 8.20 (Berkeley) 5/20/95
- * $Id: union_subr.c,v 1.28 1998/02/10 03:32:05 kato Exp $
+ * $Id: union_subr.c,v 1.29 1998/02/26 03:23:54 kato Exp $
*/
#include <sys/param.h>
@@ -830,6 +830,7 @@ union_mkshadow(um, dvp, cnp, vpp)
VOP_LEASE(dvp, p, cn.cn_cred, LEASE_WRITE);
error = VOP_MKDIR(dvp, vpp, &cn, &va);
+ vput(dvp);
return (error);
}
@@ -955,7 +956,9 @@ union_vn_create(vpp, un, p)
vap->va_type = VREG;
vap->va_mode = cmode;
VOP_LEASE(un->un_dirvp, p, cred, LEASE_WRITE);
- if (error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap))
+ error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap);
+ vput(un->un_dirvp);
+ if (error)
return (error);
error = VOP_OPEN(vp, fmode, cred, p);
diff --git a/sys/miscfs/union/union_vnops.c b/sys/miscfs/union/union_vnops.c
index e9a7a76..f1c6d78 100644
--- a/sys/miscfs/union/union_vnops.c
+++ b/sys/miscfs/union/union_vnops.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* @(#)union_vnops.c 8.32 (Berkeley) 6/23/95
- * $Id: union_vnops.c,v 1.55 1998/02/26 03:23:56 kato Exp $
+ * $Id: union_vnops.c,v 1.56 1998/03/17 08:47:50 kato Exp $
*/
#include <sys/param.h>
@@ -490,34 +490,36 @@ union_create(ap)
struct vattr *a_vap;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
struct mount *mp;
+ int error;
- FIXUP(un, p);
+ FIXUP(dun, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
- mp = ap->a_dvp->v_mount;
- vput(ap->a_dvp);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_CREATE(dvp, &vp, cnp, ap->a_vap);
- if (error)
+ if (error) {
+ dun->un_flags |= UN_ULOCK;
return (error);
+ }
+ mp = ap->a_dvp->v_mount;
+ VOP_UNLOCK(dvp, 0, p);
error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP, cnp, vp,
NULLVP, 1);
if (error)
vput(vp);
+ vn_lock(ap->a_dvp, LK_EXCLUSIVE| LK_RETRY, p);
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
@@ -549,36 +551,40 @@ union_mknod(ap)
struct vattr *a_vap;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
struct mount *mp;
+ int error;
- FIXUP(un, p);
+ FIXUP(dun, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
- mp = ap->a_dvp->v_mount;
- vput(ap->a_dvp);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_MKNOD(dvp, &vp, cnp, ap->a_vap);
- if (error)
+ if (error) {
+ dun->un_flags |= UN_ULOCK;
return (error);
+ }
if (vp != NULLVP) {
+ mp = ap->a_dvp->v_mount;
+ VOP_UNLOCK(dvp, 0, p);
error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
cnp, vp, NULLVP, 1);
if (error)
vput(vp);
+ vn_lock(ap->a_dvp, LK_EXCLUSIVE| LK_RETRY, p);
+ } else {
+ dun->un_flags |= UN_ULOCK;
}
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
@@ -1055,11 +1061,11 @@ union_remove(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error;
struct union_node *dun = VTOUNION(ap->a_dvp);
struct union_node *un = VTOUNION(ap->a_vp);
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
+ int error;
if (dun->un_uppervp == NULLVP)
panic("union remove: null upper vnode");
@@ -1069,15 +1075,13 @@ union_remove(ap)
struct vnode *vp = un->un_uppervp;
FIXUP(dun, p);
- VREF(dvp);
dun->un_flags |= UN_KLOCK;
- vput(ap->a_dvp);
+ VOP_UNLOCK(ap->a_dvp, 0, p);
FIXUP(un, p);
- VREF(vp);
un->un_flags |= UN_KLOCK;
- vput(ap->a_vp);
+ VOP_UNLOCK(ap->a_vp, 0, p);
- if (union_dowhiteout(un, cnp->cn_cred, cnp->cn_proc))
+ if (union_dowhiteout(un, cnp->cn_cred, p))
cnp->cn_flags |= DOWHITEOUT;
error = VOP_REMOVE(dvp, vp, cnp);
#if 0
@@ -1085,13 +1089,13 @@ union_remove(ap)
if (!error)
union_removed_upper(un);
#endif
+ dun->un_flags |= UN_ULOCK;
+ un->un_flags |= UN_ULOCK;
} else {
FIXUP(dun, p);
error = union_mkwhiteout(
MOUNTTOUNIONMOUNT(UNIONTOV(dun)->v_mount),
dun->un_uppervp, ap->a_cnp, un->un_path);
- vput(ap->a_dvp);
- vput(ap->a_vp);
}
return (error);
@@ -1105,14 +1109,13 @@ union_link(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error = 0;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
- struct union_node *un;
+ struct union_node *dun = VTOUNION(ap->a_tdvp);
struct vnode *vp;
struct vnode *tdvp;
+ int error = 0;
- un = VTOUNION(ap->a_tdvp);
if (ap->a_tdvp->v_op != ap->a_vp->v_op) {
vp = ap->a_vp;
@@ -1120,36 +1123,37 @@ union_link(ap)
struct union_node *tun = VTOUNION(ap->a_vp);
if (tun->un_uppervp == NULLVP) {
vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (un->un_uppervp == tun->un_dirvp) {
- un->un_flags &= ~UN_ULOCK;
- VOP_UNLOCK(un->un_uppervp, 0, p);
+ if (dun->un_uppervp == tun->un_dirvp) {
+ dun->un_flags &= ~UN_ULOCK;
+ VOP_UNLOCK(dun->un_uppervp, 0, p);
}
error = union_copyup(tun, 1, cnp->cn_cred, p);
- if (un->un_uppervp == tun->un_dirvp) {
- vn_lock(un->un_uppervp,
+ if (dun->un_uppervp == tun->un_dirvp) {
+ vn_lock(dun->un_uppervp,
LK_EXCLUSIVE | LK_RETRY, p);
- un->un_flags |= UN_ULOCK;
+ dun->un_flags |= UN_ULOCK;
}
VOP_UNLOCK(ap->a_vp, 0, p);
}
vp = tun->un_uppervp;
}
- tdvp = un->un_uppervp;
+ tdvp = dun->un_uppervp;
if (tdvp == NULLVP)
error = EROFS;
- if (error) {
- vput(ap->a_tdvp);
+ if (error)
return (error);
- }
- FIXUP(un, p);
- VREF(tdvp);
- un->un_flags |= UN_KLOCK;
- vput(ap->a_tdvp);
+ FIXUP(dun, p);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_tdvp, 0, p);
+
+ error = VOP_LINK(tdvp, vp, cnp);
- return (VOP_LINK(tdvp, vp, cnp));
+ dun->un_flags |= UN_ULOCK;
+
+ return (error);
}
static int
@@ -1255,34 +1259,34 @@ union_mkdir(ap)
struct vattr *a_vap;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
+ int error;
- FIXUP(un, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
+ FIXUP(dun, p);
+ dun->un_flags |= UN_KLOCK;
VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_MKDIR(dvp, &vp, cnp, ap->a_vap);
if (error) {
- vrele(ap->a_dvp);
+ dun->un_flags |= UN_ULOCK;
return (error);
}
+ VOP_UNLOCK(dvp, 0, p);
error = union_allocvp(ap->a_vpp, ap->a_dvp->v_mount, ap->a_dvp,
NULLVP, cnp, vp, NULLVP, 1);
- vrele(ap->a_dvp);
if (error)
vput(vp);
+ vn_lock(ap->a_dvp, LK_EXCLUSIVE| LK_RETRY, p);
+
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
@@ -1294,11 +1298,11 @@ union_rmdir(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error;
struct union_node *dun = VTOUNION(ap->a_dvp);
struct union_node *un = VTOUNION(ap->a_vp);
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
+ int error;
if (dun->un_uppervp == NULLVP)
panic("union rmdir: null upper vnode");
@@ -1308,15 +1312,13 @@ union_rmdir(ap)
struct vnode *vp = un->un_uppervp;
FIXUP(dun, p);
- VREF(dvp);
dun->un_flags |= UN_KLOCK;
- vput(ap->a_dvp);
+ VOP_UNLOCK(ap->a_dvp, 0, p);
FIXUP(un, p);
- VREF(vp);
un->un_flags |= UN_KLOCK;
- vput(ap->a_vp);
+ VOP_UNLOCK(ap->a_vp, 0, p);
- if (union_dowhiteout(un, cnp->cn_cred, cnp->cn_proc))
+ if (union_dowhiteout(un, cnp->cn_cred, p))
cnp->cn_flags |= DOWHITEOUT;
error = VOP_RMDIR(dvp, vp, ap->a_cnp);
#if 0
@@ -1324,13 +1326,13 @@ union_rmdir(ap)
if (!error)
union_removed_upper(un);
#endif
+ dun->un_flags |= UN_ULOCK;
+ un->un_flags |= UN_ULOCK;
} else {
FIXUP(dun, p);
error = union_mkwhiteout(
MOUNTTOUNIONMOUNT(UNIONTOV(dun)->v_mount),
dun->un_uppervp, ap->a_cnp, un->un_path);
- vput(ap->a_dvp);
- vput(ap->a_vp);
}
return (error);
@@ -1346,25 +1348,24 @@ union_symlink(ap)
char *a_target;
} */ *ap;
{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct vnode *dvp = un->un_uppervp;
+ struct union_node *dun = VTOUNION(ap->a_dvp);
+ struct vnode *dvp = dun->un_uppervp;
struct componentname *cnp = ap->a_cnp;
struct proc *p = cnp->cn_proc;
if (dvp != NULLVP) {
- int error;
struct vnode *vp;
+ int error;
- FIXUP(un, p);
- VREF(dvp);
- un->un_flags |= UN_KLOCK;
- vput(ap->a_dvp);
+ FIXUP(dun, p);
+ dun->un_flags |= UN_KLOCK;
+ VOP_UNLOCK(ap->a_dvp, 0, p);
error = VOP_SYMLINK(dvp, &vp, cnp, ap->a_vap, ap->a_target);
+ dun->un_flags |= UN_ULOCK;
*ap->a_vpp = NULLVP;
return (error);
}
- vput(ap->a_dvp);
return (EROFS);
}
diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c
index 4185114..555b271 100644
--- a/sys/msdosfs/msdosfs_vnops.c
+++ b/sys/msdosfs/msdosfs_vnops.c
@@ -1,4 +1,4 @@
-/* $Id: msdosfs_vnops.c,v 1.66 1998/03/20 02:33:42 kato Exp $ */
+/* $Id: msdosfs_vnops.c,v 1.67 1998/03/26 20:52:58 phk Exp $ */
/* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */
/*-
@@ -187,13 +187,11 @@ msdosfs_create(ap)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
*ap->a_vpp = DETOV(dep);
return (0);
bad:
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
return (error);
}
@@ -218,7 +216,6 @@ msdosfs_mknod(ap)
default:
zfree(namei_zone, ap->a_cnp->cn_pnbuf);
- vput(ap->a_dvp);
return (EINVAL);
}
/* NOTREACHED */
@@ -872,9 +869,9 @@ msdosfs_remove(ap)
struct componentname *a_cnp;
} */ *ap;
{
- int error;
struct denode *dep = VTODE(ap->a_vp);
struct denode *ddep = VTODE(ap->a_dvp);
+ int error;
if (ap->a_vp->v_type == VDIR)
error = EPERM;
@@ -883,12 +880,6 @@ msdosfs_remove(ap)
#ifdef MSDOSFS_DEBUG
printf("msdosfs_remove(), dep %p, v_usecount %d\n", dep, ap->a_vp->v_usecount);
#endif
- if (ddep == dep)
- vrele(ap->a_vp);
- else
- vput(ap->a_vp); /* causes msdosfs_inactive() to be called
- * via vrele() */
- vput(ap->a_dvp);
return (error);
}
@@ -906,8 +897,7 @@ msdosfs_link(ap)
} */ *ap;
{
VOP_ABORTOP(ap->a_tdvp, ap->a_cnp);
- vput(ap->a_tdvp);
- return EOPNOTSUPP;
+ return (EOPNOTSUPP);
}
/*
@@ -1324,15 +1314,15 @@ msdosfs_mkdir(ap)
} */ *ap;
{
struct componentname *cnp = ap->a_cnp;
- struct denode ndirent;
struct denode *dep;
struct denode *pdep = VTODE(ap->a_dvp);
- int error;
- int bn;
- u_long newcluster, pcl;
struct direntry *denp;
struct msdosfsmount *pmp = pdep->de_pmp;
struct buf *bp;
+ u_long newcluster, pcl;
+ int bn;
+ int error;
+ struct denode ndirent;
struct timespec ts;
/*
@@ -1419,7 +1409,6 @@ msdosfs_mkdir(ap)
goto bad;
if ((cnp->cn_flags & SAVESTART) == 0)
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
*ap->a_vpp = DETOV(dep);
return (0);
@@ -1427,7 +1416,6 @@ bad:
clusterfree(pmp, newcluster, NULL);
bad2:
zfree(namei_zone, cnp->cn_pnbuf);
- vput(ap->a_dvp);
return (error);
}
@@ -1443,6 +1431,7 @@ msdosfs_rmdir(ap)
register struct vnode *dvp = ap->a_dvp;
register struct componentname *cnp = ap->a_cnp;
register struct denode *ip, *dp;
+ struct proc *p = cnp->cn_proc;
int error;
ip = VTODE(vp);
@@ -1474,20 +1463,18 @@ msdosfs_rmdir(ap)
/*
* This is where we decrement the link count in the parent
* directory. Since dos filesystems don't do this we just purge
- * the name cache and let go of the parent directory denode.
+ * the name cache.
*/
cache_purge(dvp);
- vput(dvp);
- dvp = NULL;
+ VOP_UNLOCK(dvp, 0, p);
/*
* Truncate the directory that is being deleted.
*/
- error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, cnp->cn_proc);
+ error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, p);
cache_purge(vp);
+
+ vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
out:
- if (dvp)
- vput(dvp);
- vput(vp);
return (error);
}
@@ -1506,7 +1493,6 @@ msdosfs_symlink(ap)
{
zfree(namei_zone, ap->a_cnp->cn_pnbuf);
/* VOP_ABORTOP(ap->a_dvp, ap->a_cnp); ??? */
- vput(ap->a_dvp);
return (EOPNOTSUPP);
}
diff --git a/sys/netinet/mlf_ipl.c b/sys/netinet/mlf_ipl.c
index 8573f75..7a2cc70 100644
--- a/sys/netinet/mlf_ipl.c
+++ b/sys/netinet/mlf_ipl.c
@@ -242,6 +242,12 @@ static int if_ipl_remove __P((void))
vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
VOP_LEASE(nd.ni_dvp, curproc, curproc->p_ucred, LEASE_WRITE);
(void) VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (nd.ni_vp != NULLVP)
+ vput(nd.ni_vp);
}
return 0;
@@ -294,6 +300,7 @@ int cmd;
vattr.va_rdev = (ipl_major << 8) | i;
VOP_LEASE(nd.ni_dvp, curproc, curproc->p_ucred, LEASE_WRITE);
error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ vput(nd.ni_dvp);
if (error)
return error;
}
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c
index 4b577cb..b938de1 100644
--- a/sys/nfs/nfs_serv.c
+++ b/sys/nfs/nfs_serv.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94
- * $Id: nfs_serv.c,v 1.58 1998/02/09 06:10:35 eivind Exp $
+ * $Id: nfs_serv.c,v 1.59 1998/03/30 09:53:56 phk Exp $
*/
/*
@@ -1458,6 +1458,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
if (!error) {
nfsrv_object_create(nd.ni_vp);
zfree(namei_zone, nd.ni_cnd.cn_pnbuf);
@@ -1485,7 +1486,9 @@ nfsrv_create(nfsd, slp, procp, mrq)
} else
vap->va_rdev = (dev_t)rdev;
nqsrv_getl(nd.ni_dvp, ND_WRITE);
- if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
+ if (error) {
vrele(nd.ni_startdir);
nfsm_reply(0);
}
@@ -1666,6 +1669,7 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
if (!error)
zfree(namei_zone, nd.ni_cnd.cn_pnbuf);
} else {
@@ -1677,7 +1681,9 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
goto out;
}
nqsrv_getl(nd.ni_dvp, ND_WRITE);
- if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
+ if (error) {
vrele(nd.ni_startdir);
goto out;
}
@@ -1800,12 +1806,13 @@ out:
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(vp);
}
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP);
+ vput(vp);
}
if (dirp && v3) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
@@ -2098,6 +2105,7 @@ out:
nqsrv_getl(vp, ND_WRITE);
nqsrv_getl(xp, ND_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
+ vput(nd.ni_dvp);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == nd.ni_vp)
@@ -2209,6 +2217,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
}
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp);
+ vput(nd.ni_dvp);
if (error)
vrele(nd.ni_startdir);
else {
@@ -2343,6 +2352,7 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
}
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
if (!error) {
vp = nd.ni_vp;
bzero((caddr_t)fhp, sizeof(nfh));
@@ -2459,12 +2469,13 @@ out:
error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(vp);
}
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP)
+ vput(vp);
if (dirp) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
vrele(dirp);
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index c25fae5..a3d222f 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95
- * $Id: nfs_vnops.c,v 1.82 1998/03/28 12:04:40 bde Exp $
+ * $Id: nfs_vnops.c,v 1.83 1998/03/30 09:54:32 phk Exp $
*/
@@ -1212,12 +1212,10 @@ nfs_mknodrpc(dvp, vpp, cnp, vap)
rdev = 0xffffffff;
else {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (EOPNOTSUPP);
}
if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (error);
}
nfsstats.rpccnt[NFSPROC_MKNOD]++;
@@ -1273,7 +1271,6 @@ nfs_mknodrpc(dvp, vpp, cnp, vap)
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
- vput(dvp);
return (error);
}
@@ -1337,7 +1334,6 @@ nfs_create(ap)
if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (error);
}
if (vap->va_vaflags & VA_EXCLUSIVE)
@@ -1410,7 +1406,6 @@ again:
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
- vput(dvp);
return (error);
}
@@ -1479,11 +1474,6 @@ nfs_remove(ap)
error = nfs_sillyrename(dvp, vp, cnp);
zfree(namei_zone, cnp->cn_pnbuf);
np->n_attrstamp = 0;
- vput(dvp);
- if (vp == dvp)
- vrele(vp);
- else
- vput(vp);
return (error);
}
@@ -1686,10 +1676,6 @@ nfs_link(ap)
if (vp->v_mount != tdvp->v_mount) {
VOP_ABORTOP(vp, cnp);
- if (tdvp == vp)
- vrele(tdvp);
- else
- vput(tdvp);
return (EXDEV);
}
@@ -1718,7 +1704,6 @@ nfs_link(ap)
VTONFS(vp)->n_attrstamp = 0;
if (!wccflag)
VTONFS(tdvp)->n_attrstamp = 0;
- vput(tdvp);
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
@@ -1788,7 +1773,6 @@ nfs_symlink(ap)
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
- vput(dvp);
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
@@ -1829,7 +1813,6 @@ nfs_mkdir(ap)
if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (error);
}
len = cnp->cn_namelen;
@@ -1882,7 +1865,6 @@ nfs_mkdir(ap)
} else
*ap->a_vpp = newvp;
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
}
@@ -1923,8 +1905,6 @@ nfs_rmdir(ap)
VTONFS(dvp)->n_attrstamp = 0;
cache_purge(dvp);
cache_purge(vp);
- vput(vp);
- vput(dvp);
/*
* Kludge: Map ENOENT => 0 assuming that you have a reply to a retry.
*/
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index c25fae5..a3d222f 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95
- * $Id: nfs_vnops.c,v 1.82 1998/03/28 12:04:40 bde Exp $
+ * $Id: nfs_vnops.c,v 1.83 1998/03/30 09:54:32 phk Exp $
*/
@@ -1212,12 +1212,10 @@ nfs_mknodrpc(dvp, vpp, cnp, vap)
rdev = 0xffffffff;
else {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (EOPNOTSUPP);
}
if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (error);
}
nfsstats.rpccnt[NFSPROC_MKNOD]++;
@@ -1273,7 +1271,6 @@ nfs_mknodrpc(dvp, vpp, cnp, vap)
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
- vput(dvp);
return (error);
}
@@ -1337,7 +1334,6 @@ nfs_create(ap)
if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (error);
}
if (vap->va_vaflags & VA_EXCLUSIVE)
@@ -1410,7 +1406,6 @@ again:
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
- vput(dvp);
return (error);
}
@@ -1479,11 +1474,6 @@ nfs_remove(ap)
error = nfs_sillyrename(dvp, vp, cnp);
zfree(namei_zone, cnp->cn_pnbuf);
np->n_attrstamp = 0;
- vput(dvp);
- if (vp == dvp)
- vrele(vp);
- else
- vput(vp);
return (error);
}
@@ -1686,10 +1676,6 @@ nfs_link(ap)
if (vp->v_mount != tdvp->v_mount) {
VOP_ABORTOP(vp, cnp);
- if (tdvp == vp)
- vrele(tdvp);
- else
- vput(tdvp);
return (EXDEV);
}
@@ -1718,7 +1704,6 @@ nfs_link(ap)
VTONFS(vp)->n_attrstamp = 0;
if (!wccflag)
VTONFS(tdvp)->n_attrstamp = 0;
- vput(tdvp);
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
@@ -1788,7 +1773,6 @@ nfs_symlink(ap)
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
VTONFS(dvp)->n_attrstamp = 0;
- vput(dvp);
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
@@ -1829,7 +1813,6 @@ nfs_mkdir(ap)
if (error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) {
VOP_ABORTOP(dvp, cnp);
- vput(dvp);
return (error);
}
len = cnp->cn_namelen;
@@ -1882,7 +1865,6 @@ nfs_mkdir(ap)
} else
*ap->a_vpp = newvp;
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
}
@@ -1923,8 +1905,6 @@ nfs_rmdir(ap)
VTONFS(dvp)->n_attrstamp = 0;
cache_purge(dvp);
cache_purge(vp);
- vput(vp);
- vput(dvp);
/*
* Kludge: Map ENOENT => 0 assuming that you have a reply to a retry.
*/
diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c
index 4b577cb..b938de1 100644
--- a/sys/nfsserver/nfs_serv.c
+++ b/sys/nfsserver/nfs_serv.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_serv.c 8.3 (Berkeley) 1/12/94
- * $Id: nfs_serv.c,v 1.58 1998/02/09 06:10:35 eivind Exp $
+ * $Id: nfs_serv.c,v 1.59 1998/03/30 09:53:56 phk Exp $
*/
/*
@@ -1458,6 +1458,7 @@ nfsrv_create(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
if (!error) {
nfsrv_object_create(nd.ni_vp);
zfree(namei_zone, nd.ni_cnd.cn_pnbuf);
@@ -1485,7 +1486,9 @@ nfsrv_create(nfsd, slp, procp, mrq)
} else
vap->va_rdev = (dev_t)rdev;
nqsrv_getl(nd.ni_dvp, ND_WRITE);
- if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
+ if (error) {
vrele(nd.ni_startdir);
nfsm_reply(0);
}
@@ -1666,6 +1669,7 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
vrele(nd.ni_startdir);
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
if (!error)
zfree(namei_zone, nd.ni_cnd.cn_pnbuf);
} else {
@@ -1677,7 +1681,9 @@ nfsrv_mknod(nfsd, slp, procp, mrq)
goto out;
}
nqsrv_getl(nd.ni_dvp, ND_WRITE);
- if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) {
+ error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
+ if (error) {
vrele(nd.ni_startdir);
goto out;
}
@@ -1800,12 +1806,13 @@ out:
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(vp);
}
+ if (nd.ni_dvp == vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP);
+ vput(vp);
}
if (dirp && v3) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
@@ -2098,6 +2105,7 @@ out:
nqsrv_getl(vp, ND_WRITE);
nqsrv_getl(xp, ND_WRITE);
error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
+ vput(nd.ni_dvp);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == nd.ni_vp)
@@ -2209,6 +2217,7 @@ nfsrv_symlink(nfsd, slp, procp, mrq)
}
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp);
+ vput(nd.ni_dvp);
if (error)
vrele(nd.ni_startdir);
else {
@@ -2343,6 +2352,7 @@ nfsrv_mkdir(nfsd, slp, procp, mrq)
}
nqsrv_getl(nd.ni_dvp, ND_WRITE);
error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
+ vput(nd.ni_dvp);
if (!error) {
vp = nd.ni_vp;
bzero((caddr_t)fhp, sizeof(nfh));
@@ -2459,12 +2469,13 @@ out:
error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
} else {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vput(vp);
}
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ if (vp != NULLVP)
+ vput(vp);
if (dirp) {
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
vrele(dirp);
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 7b65d4d..8a5db2a 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95
- * $Id: ufs_vnops.c,v 1.82 1998/04/04 13:26:20 phk Exp $
+ * $Id: ufs_vnops.c,v 1.83 1998/04/17 22:37:19 des Exp $
*/
#include "opt_quota.h"
@@ -695,11 +695,6 @@ ufs_remove(ap)
VN_POLLEVENT(vp, POLLNLINK);
VN_POLLEVENT(dvp, POLLWRITE);
out:
- if (dvp == vp)
- vrele(vp);
- else
- vput(vp);
- vput(dvp);
return (error);
}
@@ -771,7 +766,6 @@ out1:
out2:
VN_POLLEVENT(vp, POLLNLINK);
VN_POLLEVENT(tdvp, POLLWRITE);
- vput(tdvp);
return (error);
}
@@ -962,7 +956,14 @@ abortit:
#endif
return (ENOENT);
}
- return (VOP_REMOVE(fdvp, fvp, fcnp));
+ error = VOP_REMOVE(fdvp, fvp, fcnp);
+ /* XXX - temporarily simulate previous rele behavior */
+ if (fdvp == fvp)
+ vrele(fdvp);
+ else
+ vput(fdvp);
+ vput(fvp);
+ return (error);
}
if (error = vn_lock(fvp, LK_EXCLUSIVE, p))
goto abortit;
@@ -1330,7 +1331,6 @@ ufs_mkdir(ap)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, dmode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -1343,7 +1343,6 @@ ufs_mkdir(ap)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, dmode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -1430,7 +1429,6 @@ bad:
}
out:
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
}
@@ -1508,9 +1506,7 @@ ufs_rmdir(ap)
}
cache_purge(vp);
out:
- vput(dvp);
VN_POLLEVENT(vp, POLLNLINK);
- vput(vp);
return (error);
}
@@ -2039,7 +2035,6 @@ ufs_makeinode(mode, dvp, vpp, cnp)
error = UFS_VALLOC(dvp, mode, cnp->cn_cred, &tvp);
if (error) {
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
return (error);
}
ip = VTOI(tvp);
@@ -2085,7 +2080,6 @@ ufs_makeinode(mode, dvp, vpp, cnp)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, mode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -2098,7 +2092,6 @@ ufs_makeinode(mode, dvp, vpp, cnp)
zfree(namei_zone, cnp->cn_pnbuf);
UFS_VFREE(tvp, ip->i_number, mode);
vput(tvp);
- vput(dvp);
return (error);
}
#endif
@@ -2131,7 +2124,6 @@ ufs_makeinode(mode, dvp, vpp, cnp)
if ((cnp->cn_flags & SAVESTART) == 0)
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
*vpp = tvp;
return (0);
@@ -2141,7 +2133,6 @@ bad:
* or the directory so must deallocate the inode.
*/
zfree(namei_zone, cnp->cn_pnbuf);
- vput(dvp);
ip->i_effnlink = 0;
ip->i_nlink = 0;
ip->i_flag |= IN_CHANGE;
OpenPOWER on IntegriCloud