Thu Apr 23 22:58:36 2020 UTC ()
cache_lookup_linked(): We can't use the name to decide how to lock the dir,
since the name refers to the child (found object) not the parent (the thing
that's being locked).

Fix it by always doing rw_tryenter().  There's not much to be won by
optimising for the contended case, and were this routine doing lockless
lookups (the eventual goal) it wouldn't be hanging around waiting for
changes either.


(ad)
diff -r1.140 -r1.141 src/sys/kern/vfs_cache.c

cvs diff -r1.140 -r1.141 src/sys/kern/vfs_cache.c (expand / switch to context diff)
--- src/sys/kern/vfs_cache.c 2020/04/22 21:35:52 1.140
+++ src/sys/kern/vfs_cache.c 2020/04/23 22:58:36 1.141
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_cache.c,v 1.140 2020/04/22 21:35:52 ad Exp $	*/
+/*	$NetBSD: vfs_cache.c,v 1.141 2020/04/23 22:58:36 ad Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -172,7 +172,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.140 2020/04/22 21:35:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.141 2020/04/23 22:58:36 ad Exp $");
 
 #define __NAMECACHE_PRIVATE
 #ifdef _KERNEL_OPT
@@ -668,12 +668,8 @@
 	 * on the lock as child -> parent is the wrong direction.
 	 */
 	if (*plock != &dvi->vi_nc_lock) {
-		if (namelen == 2 && name[0] == '.' && name[1] == '.') {
-			if (!rw_tryenter(&dvi->vi_nc_lock, RW_READER)) {
-				return false;
-			}
-		} else {
-			rw_enter(&dvi->vi_nc_lock, RW_READER);
+		if (!rw_tryenter(&dvi->vi_nc_lock, RW_READER)) {
+			return false;
 		}
 		if (*plock != NULL) {
 			rw_exit(*plock);