From d9338897d13b1fdf4cc82cc76c3a0b982bfeb330 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 3 Apr 2005 23:50:20 +0000 Subject: - Include opt_vfs.h for LOOKUP_SHARED. - Control the behavior of shared lookups with the lookup_shared sysctl which has its default behavior set via the LOOKUP_SHARED option. --- sys/kern/vfs_lookup.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 9177cee..709282f 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ktrace.h" #include "opt_mac.h" +#include "opt_vfs.h" #include #include @@ -52,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef KTRACE #include #endif @@ -75,6 +77,14 @@ nameiinit(void *dummy __unused) } SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL) +#ifdef LOOKUP_SHARED +static int lookup_shared = 1; +#else +static int lookup_shared = 0; +#endif +SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RW, &lookup_shared, 0, + "Enables/Disables shared locks for path name translation"); + /* * Convert a pathname into a pointer to a locked inode. * @@ -117,9 +127,8 @@ namei(ndp) ("namei: nameiop contaminated with flags")); KASSERT((cnp->cn_flags & OPMASK) == 0, ("namei: flags contaminated with nameiops")); -#ifndef LOOKUP_SHARED - cnp->cn_flags &= ~LOCKSHARED; -#endif + if (!lookup_shared) + cnp->cn_flags &= ~LOCKSHARED; fdp = p->p_fd; /* @@ -362,15 +371,14 @@ lookup(ndp) rdonly = cnp->cn_flags & RDONLY; cnp->cn_flags &= ~ISSYMLINK; ndp->ni_dvp = NULL; -#ifdef LOOKUP_SHARED /* * We use shared locks until we hit the parent of the last cn then * we adjust based on the requesting flags. */ - cnp->cn_lkflags = LK_SHARED; -#else - cnp->cn_lkflags = LK_EXCLUSIVE; -#endif + if (lookup_shared) + cnp->cn_lkflags = LK_SHARED; + else + cnp->cn_lkflags = LK_EXCLUSIVE; dp = ndp->ni_startdir; ndp->ni_startdir = NULLVP; vn_lock(dp, cnp->cn_lkflags | LK_RETRY, td); -- cgit v1.1