Author: mjg
Date: Sat Jul  4 15:46:39 2015
New Revision: 285135
URL: https://svnweb.freebsd.org/changeset/base/285135

Log:
  vfs: use shared vnode locking when looking up ".." in vop_stdvptocnp
  
  Briefly discussed with: kib

Modified:
  head/sys/kern/vfs_default.c

Modified: head/sys/kern/vfs_default.c
==============================================================================
--- head/sys/kern/vfs_default.c Sat Jul  4 15:42:03 2015        (r285134)
+++ head/sys/kern/vfs_default.c Sat Jul  4 15:46:39 2015        (r285135)
@@ -810,7 +810,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *
        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 *
                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 *
                    (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;
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to