Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys No need to cache anonymous device vnodes, they will neve...
details: https://anonhg.NetBSD.org/src/rev/3687fe4ce6a6
branches: trunk
changeset: 355905:3687fe4ce6a6
user: hannken <hannken%NetBSD.org@localhost>
date: Mon Aug 21 08:56:45 2017 +0000
description:
No need to cache anonymous device vnodes, they will never be looked up.
Set key to (dead_rootmount, 0, NULL) and add assertions.
diffstat:
sys/kern/vfs_vnode.c | 62 ++++++++++++++++++++++++----------------
sys/miscfs/deadfs/dead_vfsops.c | 8 ++--
2 files changed, 41 insertions(+), 29 deletions(-)
diffs (138 lines):
diff -r f4117f2fb3c0 -r 3687fe4ce6a6 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Mon Aug 21 07:38:42 2017 +0000
+++ b/sys/kern/vfs_vnode.c Mon Aug 21 08:56:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.96 2017/06/04 08:05:42 hannken Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.97 2017/08/21 08:56:45 hannken Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.96 2017/06/04 08:05:42 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.97 2017/08/21 08:56:45 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -1028,6 +1028,8 @@
{
uint32_t hash = HASH32_BUF_INIT;
+ KASSERT(key->vk_key_len > 0);
+
hash = hash32_buf(&key->vk_mount, sizeof(struct mount *), hash);
hash = hash32_buf(key->vk_key, key->vk_key_len, hash);
return hash;
@@ -1381,23 +1383,29 @@
KASSERT(*vpp == NULL);
return error;
}
- KASSERT(vip->vi_key.vk_key != NULL);
KASSERT(vp->v_op != NULL);
- hash = vcache_hash(&vip->vi_key);
+ KASSERT((vip->vi_key.vk_key_len == 0) == (mp == dead_rootmount));
+ if (vip->vi_key.vk_key_len > 0) {
+ KASSERT(vip->vi_key.vk_key != NULL);
+ hash = vcache_hash(&vip->vi_key);
- /* Wait for previous instance to be reclaimed, then insert new node. */
- mutex_enter(&vcache_lock);
- while ((ovip = vcache_hash_lookup(&vip->vi_key, hash))) {
- ovp = VIMPL_TO_VNODE(ovip);
- mutex_enter(ovp->v_interlock);
+ /*
+ * Wait for previous instance to be reclaimed,
+ * then insert new node.
+ */
+ mutex_enter(&vcache_lock);
+ while ((ovip = vcache_hash_lookup(&vip->vi_key, hash))) {
+ ovp = VIMPL_TO_VNODE(ovip);
+ mutex_enter(ovp->v_interlock);
+ mutex_exit(&vcache_lock);
+ error = vcache_vget(ovp);
+ KASSERT(error == ENOENT);
+ mutex_enter(&vcache_lock);
+ }
+ SLIST_INSERT_HEAD(&vcache_hashtab[hash & vcache_hashmask],
+ vip, vi_hash);
mutex_exit(&vcache_lock);
- error = vcache_vget(ovp);
- KASSERT(error == ENOENT);
- mutex_enter(&vcache_lock);
}
- SLIST_INSERT_HEAD(&vcache_hashtab[hash & vcache_hashmask],
- vip, vi_hash);
- mutex_exit(&vcache_lock);
vfs_insmntque(vp, mp);
if ((mp->mnt_iflag & IMNT_MPSAFE) != 0)
vp->v_vflag |= VV_MPSAFE;
@@ -1556,10 +1564,12 @@
} else {
temp_key = temp_buf;
}
- mutex_enter(&vcache_lock);
- memcpy(temp_key, vip->vi_key.vk_key, temp_key_len);
- vip->vi_key.vk_key = temp_key;
- mutex_exit(&vcache_lock);
+ if (vip->vi_key.vk_key_len > 0) {
+ mutex_enter(&vcache_lock);
+ memcpy(temp_key, vip->vi_key.vk_key, temp_key_len);
+ vip->vi_key.vk_key = temp_key;
+ mutex_exit(&vcache_lock);
+ }
fstrans_start(mp);
@@ -1604,13 +1614,15 @@
/* Purge name cache. */
cache_purge(vp);
+ if (vip->vi_key.vk_key_len > 0) {
/* Remove from vnode cache. */
- hash = vcache_hash(&vip->vi_key);
- mutex_enter(&vcache_lock);
- KASSERT(vip == vcache_hash_lookup(&vip->vi_key, hash));
- SLIST_REMOVE(&vcache_hashtab[hash & vcache_hashmask],
- vip, vnode_impl, vi_hash);
- mutex_exit(&vcache_lock);
+ hash = vcache_hash(&vip->vi_key);
+ mutex_enter(&vcache_lock);
+ KASSERT(vip == vcache_hash_lookup(&vip->vi_key, hash));
+ SLIST_REMOVE(&vcache_hashtab[hash & vcache_hashmask],
+ vip, vnode_impl, vi_hash);
+ mutex_exit(&vcache_lock);
+ }
if (temp_key != temp_buf)
kmem_free(temp_key, temp_key_len);
diff -r f4117f2fb3c0 -r 3687fe4ce6a6 sys/miscfs/deadfs/dead_vfsops.c
--- a/sys/miscfs/deadfs/dead_vfsops.c Mon Aug 21 07:38:42 2017 +0000
+++ b/sys/miscfs/deadfs/dead_vfsops.c Mon Aug 21 08:56:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dead_vfsops.c,v 1.7 2015/07/01 08:13:53 hannken Exp $ */
+/* $NetBSD: dead_vfsops.c,v 1.8 2017/08/21 08:56:45 hannken Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.7 2015/07/01 08:13:53 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dead_vfsops.c,v 1.8 2017/08/21 08:56:45 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -108,8 +108,8 @@
uvm_vnp_setsize(vp, 0);
spec_node_init(vp, vap->va_rdev);
- *key_len = sizeof(vp->v_interlock);
- *new_key = &vp->v_interlock;
+ *key_len = 0;
+ *new_key = NULL;
return 0;
}
Home |
Main Index |
Thread Index |
Old Index