Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Disentangle the namecache from the internals of namei.
details: https://anonhg.NetBSD.org/src/rev/9339536f458e
branches: trunk
changeset: 782538:9339536f458e
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Nov 05 17:24:09 2012 +0000
description:
Disentangle the namecache from the internals of namei.
- Move the namecache's hash computation to inside the namecache code,
instead of being spread out all over the place. Remove cn_hash from
struct componentname and delete all uses of it.
- It is no longer necessary (if it ever was) for cache_lookup and
cache_lookup_raw to clear MAKEENTRY from cnp->cn_flags for the cases
that cache_enter already checks for.
- Rearrange the interface of cache_lookup (and cache_lookup_raw) to
make it somewhat simpler, to exclude certain nonexistent error
conditions, and (most importantly) to make it not require write access
to cnp->cn_flags.
This change requires a kernel bump.
diffstat:
sys/fs/adosfs/adlookup.c | 9 +-
sys/fs/cd9660/cd9660_lookup.c | 9 +-
sys/fs/efs/efs_vnops.c | 10 +-
sys/fs/filecorefs/filecore_lookup.c | 9 +-
sys/fs/msdosfs/msdosfs_lookup.c | 9 +-
sys/fs/nilfs/nilfs_vnops.c | 12 +-
sys/fs/ntfs/ntfs_vnops.c | 9 +-
sys/fs/puffs/puffs_vnops.c | 36 ++++-
sys/fs/smbfs/smbfs_vnops.c | 22 +--
sys/fs/tmpfs/tmpfs_vnops.c | 18 ++-
sys/fs/udf/udf_vnops.c | 12 +-
sys/fs/union/union.h | 3 +-
sys/fs/union/union_subr.c | 26 +---
sys/kern/vfs_cache.c | 208 +++++++++++++++++++++++++----------
sys/kern/vfs_getcwd.c | 5 +-
sys/kern/vfs_lookup.c | 43 +++++--
sys/nfs/nfs_vnops.c | 34 ++---
sys/rump/librump/rumpvfs/rump_vfs.c | 6 +-
sys/sys/namei.src | 10 +-
sys/ufs/chfs/chfs_vnops.c | 6 +-
sys/ufs/ext2fs/ext2fs_lookup.c | 9 +-
sys/ufs/ufs/ufs_lookup.c | 25 +++-
22 files changed, 324 insertions(+), 206 deletions(-)
diffs (truncated from 1319 to 300 lines):
diff -r c0d5579ed38a -r 9339536f458e sys/fs/adosfs/adlookup.c
--- a/sys/fs/adosfs/adlookup.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/adosfs/adlookup.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: adlookup.c,v 1.16 2012/07/22 00:53:18 rmind Exp $ */
+/* $NetBSD: adlookup.c,v 1.17 2012/11/05 17:24:09 dholland Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.16 2012/07/22 00:53:18 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.17 2012/11/05 17:24:09 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -110,8 +110,9 @@
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
- if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
- return (error);
+ if (cache_lookup(vdp, cnp, NULL, vpp)) {
+ return *vpp == NULLVP ? ENOENT : 0;
+ }
/*
* fake a '.'
diff -r c0d5579ed38a -r 9339536f458e sys/fs/cd9660/cd9660_lookup.c
--- a/sys/fs/cd9660/cd9660_lookup.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/cd9660/cd9660_lookup.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_lookup.c,v 1.20 2012/07/22 00:53:18 rmind Exp $ */
+/* $NetBSD: cd9660_lookup.c,v 1.21 2012/11/05 17:24:09 dholland Exp $ */
/*-
* Copyright (c) 1989, 1993, 1994
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.20 2012/07/22 00:53:18 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_lookup.c,v 1.21 2012/11/05 17:24:09 dholland Exp $");
#include <sys/param.h>
#include <sys/namei.h>
@@ -151,8 +151,9 @@
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
- if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
- return (error);
+ if (cache_lookup(vdp, cnp, NULL, vpp)) {
+ return *vpp == NULLVP ? ENOENT : 0;
+ }
len = cnp->cn_namelen;
name = cnp->cn_nameptr;
diff -r c0d5579ed38a -r 9339536f458e sys/fs/efs/efs_vnops.c
--- a/sys/fs/efs/efs_vnops.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/efs/efs_vnops.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efs_vnops.c,v 1.26 2012/07/22 00:53:19 rmind Exp $ */
+/* $NetBSD: efs_vnops.c,v 1.27 2012/11/05 17:24:09 dholland Exp $ */
/*
* Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
@@ -17,7 +17,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.26 2012/07/22 00:53:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.27 2012/11/05 17:24:09 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -73,9 +73,9 @@
if (err)
return (err);
- err = cache_lookup(ap->a_dvp, ap->a_vpp, cnp);
- if (err != -1)
- return (err);
+ if (cache_lookup(ap->a_dvp, cnp, NULL, ap->a_vpp)) {
+ return *ap->a_vpp == NULLVP ? ENOENT : 0;
+ }
/*
* Handle the three lookup types: '.', '..', and everything else.
diff -r c0d5579ed38a -r 9339536f458e sys/fs/filecorefs/filecore_lookup.c
--- a/sys/fs/filecorefs/filecore_lookup.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/filecorefs/filecore_lookup.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: filecore_lookup.c,v 1.14 2012/07/22 00:53:19 rmind Exp $ */
+/* $NetBSD: filecore_lookup.c,v 1.15 2012/11/05 17:24:09 dholland Exp $ */
/*-
* Copyright (c) 1989, 1993, 1994 The Regents of the University of California.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filecore_lookup.c,v 1.14 2012/07/22 00:53:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filecore_lookup.c,v 1.15 2012/11/05 17:24:09 dholland Exp $");
#include <sys/param.h>
#include <sys/namei.h>
@@ -169,8 +169,9 @@
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
- if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
- return (error);
+ if (cache_lookup(vdp, cnp, NULL, vpp)) {
+ return *vpp == NULLVP ? ENOENT : 0;
+ }
name = cnp->cn_nameptr;
namelen = cnp->cn_namelen;
diff -r c0d5579ed38a -r 9339536f458e sys/fs/msdosfs/msdosfs_lookup.c
--- a/sys/fs/msdosfs/msdosfs_lookup.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/msdosfs/msdosfs_lookup.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_lookup.c,v 1.24 2012/07/22 00:53:19 rmind Exp $ */
+/* $NetBSD: msdosfs_lookup.c,v 1.25 2012/11/05 17:24:10 dholland Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.24 2012/07/22 00:53:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_lookup.c,v 1.25 2012/11/05 17:24:10 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -146,8 +146,9 @@
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
- if ((error = cache_lookup(vdp, vpp, cnp)) >= 0)
- return (error);
+ if (cache_lookup(vdp, cnp, NULL, vpp)) {
+ return *vpp == NULLVP ? ENOENT: 0;
+ }
/*
* If they are going after the . or .. entry in the root directory,
diff -r c0d5579ed38a -r 9339536f458e sys/fs/nilfs/nilfs_vnops.c
--- a/sys/fs/nilfs/nilfs_vnops.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/nilfs/nilfs_vnops.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.18 2012/07/22 00:53:19 rmind Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.19 2012/11/05 17:24:10 dholland Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.18 2012/07/22 00:53:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.19 2012/11/05 17:24:10 dholland Exp $");
#endif /* not lint */
@@ -652,10 +652,10 @@
DPRINTF(LOOKUP, ("\tlooking up cnp->cn_nameptr '%s'\n",
cnp->cn_nameptr));
- /* look in the nami cache; returns 0 on success!! */
- error = cache_lookup(dvp, vpp, cnp);
- if (error >= 0)
- return error;
+ /* look in the namecache */
+ if (cache_lookup(dvp, cnp, NULL, vpp)) {
+ return *vpp == NULLVP ? ENOENT : 0;
+ }
DPRINTF(LOOKUP, ("\tNOT found in cache\n"));
diff -r c0d5579ed38a -r 9339536f458e sys/fs/ntfs/ntfs_vnops.c
--- a/sys/fs/ntfs/ntfs_vnops.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/ntfs/ntfs_vnops.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_vnops.c,v 1.52 2012/07/22 00:53:19 rmind Exp $ */
+/* $NetBSD: ntfs_vnops.c,v 1.53 2012/11/05 17:24:10 dholland Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vnops.c,v 1.52 2012/07/22 00:53:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vnops.c,v 1.53 2012/11/05 17:24:10 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -682,8 +682,9 @@
* check the name cache to see if the directory/name pair
* we are looking for is known already.
*/
- if ((error = cache_lookup(ap->a_dvp, ap->a_vpp, cnp)) >= 0)
- return (error);
+ if (cache_lookup(ap->a_dvp, cnp, NULL, ap->a_vpp)) {
+ return *ap->a_vpp == NULLVP ? ENOENT : 0;
+ }
if(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
dprintf(("ntfs_lookup: faking . directory in %llu\n",
diff -r c0d5579ed38a -r 9339536f458e sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/puffs/puffs_vnops.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_vnops.c,v 1.174 2012/08/10 16:49:35 manu Exp $ */
+/* $NetBSD: puffs_vnops.c,v 1.175 2012/11/05 17:24:10 dholland Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.174 2012/08/10 16:49:35 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.175 2012/11/05 17:24:10 dholland Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -526,9 +526,14 @@
* Check if someone fed it into the cache
*/
if (!isdot && PUFFS_USE_NAMECACHE(pmp)) {
- error = cache_lookup(dvp, ap->a_vpp, cnp);
-
- if ((error == 0) && PUFFS_USE_FS_TTL(pmp)) {
+ int found, iswhiteout;
+
+ found = cache_lookup(dvp, cnp, &iswhiteout, ap->a_vpp);
+ if (iswhiteout) {
+ cnp->cn_flags |= ISWHITEOUT;
+ }
+
+ if (found && *ap->a_vpp != NULLVP && PUFFS_USE_FS_TTL(pmp)) {
cvp = *ap->a_vpp;
cpn = VPTOPP(cvp);
@@ -540,7 +545,7 @@
* successful lookup.
*/
*ap->a_vpp = NULL;
- error = -1;
+ found = 0;
}
}
@@ -548,11 +553,20 @@
* Do not use negative caching, since the filesystem
* provides no TTL for it.
*/
- if ((error == ENOENT) && PUFFS_USE_FS_TTL(pmp))
- error = -1;
-
- if (error >= 0)
- return error;
+ if (found && *ap->a_vpp == NULLVP && PUFFS_USE_FS_TTL(pmp))
+ found = 0;
+
+ if (found) {
+ return *ap->a_vpp == NULLVP ? ENOENT : 0;
+ }
+
+ /*
+ * This is what would have been left in ERROR before
+ * the rearrangement of cache_lookup(). What with all
+ * the macros, I am not sure if this is a dead value
+ * below or not.
+ */
+ error = -1;
}
if (isdot) {
diff -r c0d5579ed38a -r 9339536f458e sys/fs/smbfs/smbfs_vnops.c
--- a/sys/fs/smbfs/smbfs_vnops.c Mon Nov 05 17:16:59 2012 +0000
+++ b/sys/fs/smbfs/smbfs_vnops.c Mon Nov 05 17:24:09 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smbfs_vnops.c,v 1.80 2012/07/22 00:53:20 rmind Exp $ */
+/* $NetBSD: smbfs_vnops.c,v 1.81 2012/11/05 17:24:10 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbfs_vnops.c,v 1.80 2012/07/22 00:53:20 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbfs_vnops.c,v 1.81 2012/11/05 17:24:10 dholland Exp $");
Home |
Main Index |
Thread Index |
Old Index