summaryrefslogtreecommitdiffstats
path: root/sys/gnu
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-05-07 04:58:58 +0000
committermsmith <msmith@FreeBSD.org>1998-05-07 04:58:58 +0000
commit964ce778b1ba281a004f70a3b477fbca7c441e6b (patch)
treee3261d6a1cd9c2ca87c73ec9a35aa31aefbfc7c4 /sys/gnu
parenta64c77cceb4f88e319290462be5ec2b74e6b03a1 (diff)
downloadFreeBSD-src-964ce778b1ba281a004f70a3b477fbca7c441e6b.zip
FreeBSD-src-964ce778b1ba281a004f70a3b477fbca7c441e6b.tar.gz
In the words of the submitter:
--------- Make callers of namei() responsible for releasing references or locks instead of having the underlying filesystems do it. This eliminates redundancy in all terminal filesystems and makes it possible for stacked transport layers such as umapfs or nullfs to operate correctly. Quality testing was done with testvn, and lat_fs from the lmbench suite. Some NFS client testing courtesy of Patrik Kudo. vop_mknod and vop_symlink still release the returned vpp. vop_rename still releases 4 vnode arguments before it returns. These remaining cases will be corrected in the next set of patches. --------- Submitted by: Michael Hancock <michaelh@cet.co.jp>
Diffstat (limited to 'sys/gnu')
-rw-r--r--sys/gnu/ext2fs/ext2_vnops.c35
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vnops.c35
2 files changed, 26 insertions, 44 deletions
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);
OpenPOWER on IntegriCloud