summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2005-04-03 23:50:20 +0000
committerjeff <jeff@FreeBSD.org>2005-04-03 23:50:20 +0000
commitd9338897d13b1fdf4cc82cc76c3a0b982bfeb330 (patch)
tree58b7e7695509853df16768dcd4760685e99b12a3 /sys/kern
parentb8a893bbd419f278d3cf69b109d9aad8b92795fb (diff)
downloadFreeBSD-src-d9338897d13b1fdf4cc82cc76c3a0b982bfeb330.zip
FreeBSD-src-d9338897d13b1fdf4cc82cc76c3a0b982bfeb330.tar.gz
- 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.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_lookup.c24
1 files changed, 16 insertions, 8 deletions
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 <sys/param.h>
#include <sys/systm.h>
@@ -52,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/filedesc.h>
#include <sys/proc.h>
#include <sys/syscallsubr.h>
+#include <sys/sysctl.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#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);
OpenPOWER on IntegriCloud