Module Name: src Committed By: ad Date: Thu Apr 23 22:58:36 UTC 2020
Modified Files: src/sys/kern: vfs_cache.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/kern/vfs_cache.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_cache.c diff -u src/sys/kern/vfs_cache.c:1.140 src/sys/kern/vfs_cache.c:1.141 --- src/sys/kern/vfs_cache.c:1.140 Wed Apr 22 21:35:52 2020 +++ src/sys/kern/vfs_cache.c Thu Apr 23 22:58:36 2020 @@ -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 @@ cache_lookup_linked(struct vnode *dvp, c * 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);