Index: gnu/ext2fs/ext2_vnops.c =================================================================== RCS file: /usr/cvs/src/sys/gnu/ext2fs/ext2_vnops.c,v retrieving revision 1.37 diff -p -u -r1.37 ext2_vnops.c --- ext2_vnops.c 1998/04/17 22:36:22 1.37 +++ ext2_vnops.c 1998/05/06 10:24:42 @@ -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); Index: kern/uipc_usrreq.c =================================================================== RCS file: /usr/cvs/src/sys/kern/uipc_usrreq.c,v retrieving revision 1.33 diff -p -u -r1.33 uipc_usrreq.c --- uipc_usrreq.c 1998/04/17 22:36:50 1.33 +++ uipc_usrreq.c 1998/05/06 10:24:42 @@ -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; Index: kern/vfs_syscalls.c =================================================================== RCS file: /usr/cvs/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.99 diff -p -u -r1.99 vfs_syscalls.c --- vfs_syscalls.c 1998/04/19 22:20:32 1.99 +++ vfs_syscalls.c 1998/05/07 00:22:14 @@ -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); Index: kern/vfs_vnops.c =================================================================== RCS file: /usr/cvs/src/sys/kern/vfs_vnops.c,v retrieving revision 1.56 diff -p -u -r1.56 vfs_vnops.c --- vfs_vnops.c 1998/04/10 00:09:04 1.56 +++ vfs_vnops.c 1998/05/06 10:24:43 @@ -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"); Index: kern/vnode_if.src =================================================================== RCS file: /usr/cvs/src/sys/kern/vnode_if.src,v retrieving revision 1.16 diff -p -u -r1.16 vnode_if.src --- vnode_if.src 1998/03/08 09:57:26 1.16 +++ vnode_if.src 1998/05/06 10:24:43 @@ -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; Index: miscfs/devfs/devfs_vnops.c =================================================================== RCS file: /usr/cvs/src/sys/miscfs/devfs/devfs_vnops.c,v retrieving revision 1.54 diff -p -u -r1.54 devfs_vnops.c --- devfs_vnops.c 1998/04/19 23:32:17 1.54 +++ devfs_vnops.c 1998/05/07 00:30:15 @@ -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 *a 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; } Index: miscfs/union/union_subr.c =================================================================== RCS file: /usr/cvs/src/sys/miscfs/union/union_subr.c,v retrieving revision 1.29 diff -p -u -r1.29 union_subr.c --- union_subr.c 1998/02/26 03:23:54 1.29 +++ union_subr.c 1998/05/06 10:24:43 @@ -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); Index: miscfs/union/union_vnops.c =================================================================== RCS file: /usr/cvs/src/sys/miscfs/union/union_vnops.c,v retrieving revision 1.56 diff -p -u -r1.56 union_vnops.c --- union_vnops.c 1998/03/17 08:47:50 1.56 +++ union_vnops.c 1998/05/06 10:30:47 @@ -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); + + dun->un_flags |= UN_ULOCK; - return (VOP_LINK(tdvp, vp, cnp)); + 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); } Index: msdosfs/msdosfs_vnops.c =================================================================== RCS file: /usr/cvs/src/sys/msdosfs/msdosfs_vnops.c,v retrieving revision 1.67 diff -p -u -r1.67 msdosfs_vnops.c --- msdosfs_vnops.c 1998/03/26 20:52:58 1.67 +++ msdosfs_vnops.c 1998/05/07 00:39:31 @@ -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); } Index: netinet/mlf_ipl.c =================================================================== RCS file: /usr/cvs/src/sys/netinet/mlf_ipl.c,v retrieving revision 1.6 diff -p -u -r1.6 mlf_ipl.c --- mlf_ipl.c 1998/03/28 08:07:12 1.6 +++ mlf_ipl.c 1998/05/06 10:24:43 @@ -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; } Index: nfs/nfs_serv.c =================================================================== RCS file: /usr/cvs/src/sys/nfs/nfs_serv.c,v retrieving revision 1.59 diff -p -u -r1.59 nfs_serv.c --- nfs_serv.c 1998/03/30 09:53:56 1.59 +++ nfs_serv.c 1998/05/06 10:24:43 @@ -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); Index: nfs/nfs_vnops.c =================================================================== RCS file: /usr/cvs/src/sys/nfs/nfs_vnops.c,v retrieving revision 1.83 diff -p -u -r1.83 nfs_vnops.c --- nfs_vnops.c 1998/03/30 09:54:32 1.83 +++ nfs_vnops.c 1998/05/06 10:24:44 @@ -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. */ Index: ufs/ufs/ufs_vnops.c =================================================================== RCS file: /usr/cvs/src/sys/ufs/ufs/ufs_vnops.c,v retrieving revision 1.83 diff -p -u -r1.83 ufs_vnops.c --- ufs_vnops.c 1998/04/17 22:37:19 1.83 +++ ufs_vnops.c 1998/05/06 10:24:44 @@ -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;