summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2010-05-19 08:31:24 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2010-05-19 08:31:24 +0000
commita0866af4df0a13d49dfc920d45fada2f6db41c84 (patch)
tree0f4a6bb1e7e97da01ae92afe7f0b30a83c6c58f1 /sys
parent77f46605b921b22444cdb100b2a89118ddef8bc8 (diff)
clean up a few things that where left to rot after bob's vfs cache work.
sync a few comments to reality (or remove them), remove the cn_hash member from struct componentname, spacing. ok beck@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_cache.c35
-rw-r--r--sys/kern/vfs_getcwd.c3
-rw-r--r--sys/kern/vfs_lookup.c26
-rw-r--r--sys/nfs/nfs_subs.c4
-rw-r--r--sys/nfs/nfs_vnops.c5
-rw-r--r--sys/nnpfs/nnpfs_config.h2
-rw-r--r--sys/nnpfs/nnpfs_locl.h1
-rw-r--r--sys/sys/namei.h3
8 files changed, 31 insertions, 48 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index fa93355dd14..bc53930b5df 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_cache.c,v 1.32 2009/08/24 15:51:40 thib Exp $ */
+/* $OpenBSD: vfs_cache.c,v 1.33 2010/05/19 08:31:23 thib Exp $ */
/* $NetBSD: vfs_cache.c,v 1.13 1996/02/04 02:18:09 christos Exp $ */
/*
@@ -41,21 +41,12 @@
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/pool.h>
-#include <sys/hash.h>
/*
* TODO: namecache access should really be locked.
*/
/*
- * Name caching works as follows:
- *
- * Names found by directory scans are retained in a cache
- * for future reference. It is managed LRU, so frequently
- * used names will hang around. Cache is indexed by hash value
- * obtained from (vp, name) where vp refers to the directory
- * containing name.
- *
* For simplicity (and economy of storage), names longer than
* a maximum length of NCHNAMLEN are not cached; they occur
* infrequently in any case, and are almost never of interest.
@@ -68,11 +59,11 @@
/*
* Structures associated with name caching.
*/
-long numcache; /* total number of cache entries allocated */
-long numneg; /* number of negative cache entries */
+long numcache; /* total number of cache entries allocated */
+long numneg; /* number of negative cache entries */
-TAILQ_HEAD(, namecache) nclruhead; /* Regular Entry LRU chain */
-TAILQ_HEAD(, namecache) nclruneghead; /* Negative Entry LRU chain */
+TAILQ_HEAD(, namecache) nclruhead; /* Regular Entry LRU chain */
+TAILQ_HEAD(, namecache) nclruneghead; /* Negative Entry LRU chain */
struct nchstats nchstats; /* cache effectiveness statistics */
int doingcache = 1; /* 1 => enable the cache */
@@ -133,16 +124,12 @@ cache_zap(struct namecache *ncp)
* Look for a name in the cache. We don't do this if the segment name is
* long, simply so the cache can avoid holding long names (which would
* either waste space, or add greatly to the complexity).
- *
- * Lookup is called with ni_dvp pointing to the directory to search,
- * ni_ptr pointing to the name of the entry being sought, ni_namelen
- * tells the length of the name, and ni_hash contains a hash of
- * the name. If the lookup succeeds, the vnode is returned in ni_vp
- * and a status of 0 is returned. If the locking fails for whatever
- * reason, the vnode is unlocked and the error is returned to caller.
- * If the lookup determines that the name does not exist (negative caching),
- * a status of ENOENT is returned. If the lookup fails, a status of -1
- * is returned.
+ * dvp points to the directory to search. The componentname cnp holds
+ * the information on the entry being sought, such as its length
+ * and its name. If the lookup succeeds, vpp is set to point to the vnode
+ * and an error of 0 is returned. If the lookup determines the name does
+ * not exist (negative caching) an error of ENOENT is returned. If the
+ * lookup fails, an error of -1 is returned.
*/
int
cache_lookup(struct vnode *dvp, struct vnode **vpp,
diff --git a/sys/kern/vfs_getcwd.c b/sys/kern/vfs_getcwd.c
index ebee817eca6..4639dea989e 100644
--- a/sys/kern/vfs_getcwd.c
+++ b/sys/kern/vfs_getcwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_getcwd.c,v 1.16 2010/01/14 23:12:11 schwarze Exp $ */
+/* $OpenBSD: vfs_getcwd.c,v 1.17 2010/05/19 08:31:23 thib Exp $ */
/* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */
/*
@@ -88,7 +88,6 @@ vfs_getcwd_scandir(struct vnode **lvpp, struct vnode **uvpp, char **bpp,
cn.cn_pnbuf = NULL;
cn.cn_nameptr = "..";
cn.cn_namelen = 2;
- cn.cn_hash = 0;
cn.cn_consume = 0;
/* Get parent vnode using lookup of '..' */
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index ea8f77985b4..72b20887cb9 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_lookup.c,v 1.40 2009/07/09 22:29:56 thib Exp $ */
+/* $OpenBSD: vfs_lookup.c,v 1.41 2010/05/19 08:31:23 thib Exp $ */
/* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */
/*
@@ -360,20 +360,24 @@ dirloop:
/*
* Search a new directory.
*
- * The cn_hash value is for use by vfs_cache.
* The last component of the filename is left accessible via
* cnp->cn_nameptr for callers that need the name. Callers needing
* the name set the SAVENAME flag. When done, they assume
* responsibility for freeing the pathname buffer.
*/
- cp = NULL;
cnp->cn_consume = 0;
- cnp->cn_hash = hash32_stre(cnp->cn_nameptr, '/', &cp, HASHINIT);
+
+ /* XXX: Figure out the length of the last component. */
+ cp = cnp->cn_nameptr;
+ while (*cp && (*cp != '/')) {
+ *cp++;
+ }
cnp->cn_namelen = cp - cnp->cn_nameptr;
if (cnp->cn_namelen > NAME_MAX) {
error = ENAMETOOLONG;
goto bad;
}
+
#ifdef NAMEI_DIAGNOSTIC
{ char c = *cp;
*cp = '\0';
@@ -618,7 +622,6 @@ relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
int rdonly; /* lookup read-only flag bit */
int error = 0;
#ifdef NAMEI_DIAGNOSTIC
- u_int32_t newhash; /* DEBUG: check name hash */
char *cp; /* DEBUG: check name ptr/len */
#endif
@@ -635,19 +638,20 @@ relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
/*
* Search a new directory.
*
- * The cn_hash value is for use by vfs_cache.
* The last component of the filename is left accessible via
* cnp->cn_nameptr for callers that need the name. Callers needing
* the name set the SAVENAME flag. When done, they assume
* responsibility for freeing the pathname buffer.
*/
+
#ifdef NAMEI_DIAGNOSTIC
- cp = NULL;
- newhash = hash32_stre(cnp->cn_nameptr, '/', &cp, HASHINIT);
- if (newhash != cnp->cn_hash)
- panic("relookup: bad hash");
+ /* XXX: Figure out the length of the last component. */
+ cp = cnp->cn_nameptr;
+ while (*cp && (*cp != '/')) {
+ *cp++;
+ }
if (cnp->cn_namelen != cp - cnp->cn_nameptr)
- panic ("relookup: bad len");
+ panic("relookup: bad len");
if (*cp != 0)
panic("relookup: not last component");
printf("{%s}: ", cnp->cn_nameptr);
diff --git a/sys/nfs/nfs_subs.c b/sys/nfs/nfs_subs.c
index fc24ce12bad..eea422228d7 100644
--- a/sys/nfs/nfs_subs.c
+++ b/sys/nfs/nfs_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_subs.c,v 1.107 2009/10/19 22:24:18 jsg Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.108 2010/05/19 08:31:23 thib Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
@@ -1200,7 +1200,6 @@ nfs_namei(struct nameidata *ndp, fhandle_t *fhp, int len,
tocp = cnp->cn_pnbuf;
md = *mdp;
rem = mtod(md, caddr_t) + md->m_len - fromcp;
- cnp->cn_hash = 0;
for (i = 0; i < len; i++) {
while (rem == 0) {
md = md->m_next;
@@ -1215,7 +1214,6 @@ nfs_namei(struct nameidata *ndp, fhandle_t *fhp, int len,
error = EACCES;
goto out;
}
- cnp->cn_hash += (u_char)*fromcp;
*tocp++ = *fromcp++;
rem--;
}
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index 20e38f543bb..e2dde9025f0 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vnops.c,v 1.129 2010/04/12 16:37:38 beck Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.130 2010/05/19 08:31:23 thib Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */
/*
@@ -2427,9 +2427,6 @@ nfs_readdirplusrpc(struct vnode *vp, struct uio *uiop, struct ucred *cred,
IFTODT(VTTOIF(np->n_vattr.va_type));
if (cnp->cn_namelen <= NCHNAMLEN) {
ndp->ni_vp = newvp;
- cnp->cn_hash =
- hash32_str(cnp->cn_nameptr,
- HASHINIT);
cache_purge(ndp->ni_dvp);
nfs_cache_enter(ndp->ni_dvp, ndp->ni_vp,
cnp);
diff --git a/sys/nnpfs/nnpfs_config.h b/sys/nnpfs/nnpfs_config.h
index 68ee3f692c1..a9de59a49cf 100644
--- a/sys/nnpfs/nnpfs_config.h
+++ b/sys/nnpfs/nnpfs_config.h
@@ -953,7 +953,7 @@
/* #undef HAVE_STRUCT_CDEVSW_D_STOP */
/* Define if struct componentname has field cn_hash */
-#define HAVE_STRUCT_COMPONENTNAME_CN_HASH 1
+/* #undef HAVE_STRUCT_COMPONENTNAME_CN_HASH */
/* Define if struct dirent has field d_type. */
#define HAVE_STRUCT_DIRENT_D_TYPE 1
diff --git a/sys/nnpfs/nnpfs_locl.h b/sys/nnpfs/nnpfs_locl.h
index 0306195a217..29f0d0f875b 100644
--- a/sys/nnpfs/nnpfs_locl.h
+++ b/sys/nnpfs/nnpfs_locl.h
@@ -82,7 +82,6 @@ typedef struct nameidata nnpfs_componentname;
#define cn_nameptr ni_ptr
#define cn_namelen ni_namelen
-#define cn_hash ni_hash
#define cn_cred ni_cred
#define cn_nameiop ni_nameiop
#define cn_flags ni_flags
diff --git a/sys/sys/namei.h b/sys/sys/namei.h
index cff8952b032..96f933375fa 100644
--- a/sys/sys/namei.h
+++ b/sys/sys/namei.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: namei.h,v 1.23 2009/08/12 16:42:24 beck Exp $ */
+/* $OpenBSD: namei.h,v 1.24 2010/05/19 08:31:23 thib Exp $ */
/* $NetBSD: namei.h,v 1.11 1996/02/09 18:25:20 christos Exp $ */
/*
@@ -91,7 +91,6 @@ struct nameidata {
char *cn_pnbuf; /* pathname buffer */
char *cn_nameptr; /* pointer to looked up name */
long cn_namelen; /* length of looked up component */
- u_int32_t cn_hash; /* hash value of looked up name */
long cn_consume; /* chars to consume in lookup() */
} ni_cnd;
};