Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern cache_lookup_linked(): We can't use the name to dec...



details:   https://anonhg.NetBSD.org/src/rev/4037d6b95d64
branches:  trunk
changeset: 1009466:4037d6b95d64
user:      ad <ad%NetBSD.org@localhost>
date:      Thu Apr 23 22:58:36 2020 +0000

description:
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.

diffstat:

 sys/kern/vfs_cache.c |  12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diffs (33 lines):

diff -r dafe3bed6f9a -r 4037d6b95d64 sys/kern/vfs_cache.c
--- a/sys/kern/vfs_cache.c      Thu Apr 23 21:53:01 2020 +0000
+++ b/sys/kern/vfs_cache.c      Thu Apr 23 22:58:36 2020 +0000
@@ -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);



Home | Main Index | Thread Index | Old Index