1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

vfs: use shared vnode locking when looking up ".." in vop_stdvptocnp

Briefly discussed with: kib
This commit is contained in:
Mateusz Guzik 2015-07-04 15:46:39 +00:00
parent dba0bec2bb
commit 9ca30b0e06
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285135

View File

@ -810,7 +810,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *ap)
VREF(vp);
locked = VOP_ISLOCKED(vp);
VOP_UNLOCK(vp, 0);
NDINIT_ATVP(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,
NDINIT_ATVP(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF, UIO_SYSSPACE,
"..", vp, td);
flags = FREAD;
error = vn_open_cred(&nd, &flags, 0, VN_OPEN_NOAUDIT, cred, NULL);
@ -830,7 +830,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *ap)
VOP_UNLOCK(mvp, 0);
vn_close(mvp, FREAD, cred, td);
VREF(*dvp);
vn_lock(*dvp, LK_EXCLUSIVE | LK_RETRY);
vn_lock(*dvp, LK_SHARED | LK_RETRY);
covered = 1;
}
@ -859,15 +859,15 @@ vop_stdvptocnp(struct vop_vptocnp_args *ap)
(dp->d_fileno == fileno)) {
if (covered) {
VOP_UNLOCK(*dvp, 0);
vn_lock(mvp, LK_EXCLUSIVE | LK_RETRY);
vn_lock(mvp, LK_SHARED | LK_RETRY);
if (dirent_exists(mvp, dp->d_name, td)) {
error = ENOENT;
VOP_UNLOCK(mvp, 0);
vn_lock(*dvp, LK_EXCLUSIVE | LK_RETRY);
vn_lock(*dvp, LK_SHARED | LK_RETRY);
goto out;
}
VOP_UNLOCK(mvp, 0);
vn_lock(*dvp, LK_EXCLUSIVE | LK_RETRY);
vn_lock(*dvp, LK_SHARED | LK_RETRY);
}
i -= dp->d_namlen;