Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern cache_enter: concurrent lookups in the same directo...
details: https://anonhg.NetBSD.org/src/rev/5f958e204b08
branches: trunk
changeset: 566255:5f958e204b08
user: pk <pk%NetBSD.org@localhost>
date: Sun May 02 12:00:34 2004 +0000
description:
cache_enter: concurrent lookups in the same directory may race for a
cache entry. Upon detection, free our tentative entry and return.
diffstat:
sys/kern/vfs_cache.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diffs (53 lines):
diff -r 81eb93907728 -r 5f958e204b08 sys/kern/vfs_cache.c
--- a/sys/kern/vfs_cache.c Sun May 02 11:22:06 2004 +0000
+++ b/sys/kern/vfs_cache.c Sun May 02 12:00:34 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_cache.c,v 1.56 2004/04/25 16:42:41 simonb Exp $ */
+/* $NetBSD: vfs_cache.c,v 1.57 2004/05/02 12:00:34 pk Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.56 2004/04/25 16:42:41 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.57 2004/05/02 12:00:34 pk Exp $");
#include "opt_ddb.h"
#include "opt_revcache.h"
@@ -133,7 +133,7 @@
{
pool_put(&namecache_pool, ncp);
- numcache--; /* XXX MP */
+ numcache--;
}
static __inline struct namecache *
@@ -418,7 +418,6 @@
* Free the cache slot at head of lru chain.
*/
simple_lock(&namecache_slock);
- KASSERT(cache_lookup_entry(dvp, cnp) == NULL);
if (numcache < numvnodes) {
numcache++;
simple_unlock(&namecache_slock);
@@ -431,6 +430,17 @@
simple_unlock(&namecache_slock);
return;
}
+
+ /*
+ * Concurrent lookups in the same directory may race for a
+ * cache entry. If we loose, free our tentative entry and return.
+ */
+ if (cache_lookup_entry(dvp, cnp) != NULL) {
+ cache_free(ncp);
+ simple_unlock(&namecache_slock);
+ return;
+ }
+
/* Grab the vnode we just found. */
ncp->nc_vp = vp;
if (vp == NULL) {
Home |
Main Index |
Thread Index |
Old Index