summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerlin Scholz <merlin@scholz.ruhr>2023-04-24 20:40:15 +0200
committerMerlin Scholz <merlin@scholz.ruhr>2023-05-29 01:53:33 +0200
commit0a87be88cd120979c5e397742a55cfb564cd9f8a (patch)
tree8545e17c048203fd99e833197b38cf5a59000a87
parentdc2190d477b8fe4145170f3a029d9b53c2157140 (diff)
Instruct vnode_impl alloc/dealloc
-rw-r--r--sys/kern/vfs_vnode.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/sys/kern/vfs_vnode.c b/sys/kern/vfs_vnode.c
index 35be3e0f581..21857be018a 100644
--- a/sys/kern/vfs_vnode.c
+++ b/sys/kern/vfs_vnode.c
@@ -182,6 +182,10 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.103 2019/02/20 10:07:27 hannken Exp
#include <uvm/uvm.h>
#include <uvm/uvm_readahead.h>
+#ifdef LOCKDOC
+#include <sys/lockdoc.h>
+#endif
+
/* Flags to vrelel. */
#define VRELEL_ASYNC_RELE 0x0001 /* Always defer to vrele thread. */
#define VRELEL_FORCE_RELE 0x0002 /* Must always succeed. */
@@ -1322,6 +1326,9 @@ again:
if (error)
return error;
new_vip = vcache_alloc();
+#ifdef LOCKDOC
+ lockdoc_log_memory(1, "vnode_impl", new_vip, sizeof(vnode_impl_t));
+#endif
new_vip->vi_key = vcache_key;
vp = VIMPL_TO_VNODE(new_vip);
mutex_enter(&vcache_lock);
@@ -1334,6 +1341,9 @@ again:
/* If another thread beat us inserting this node, retry. */
if (vip != new_vip) {
+#ifdef LOCKDOC
+ lockdoc_log_memory(0, "vnode_impl", new_vip, sizeof(vnode_impl_t));
+#endif
vcache_dealloc(new_vip);
vfs_unbusy(mp);
goto again;
@@ -1346,6 +1356,9 @@ again:
mutex_enter(&vcache_lock);
SLIST_REMOVE(&vcache_hashtab[hash & vcache_hashmask],
new_vip, vnode_impl, vi_hash);
+#ifdef LOCKDOC
+ lockdoc_log_memory(0, "vnode_impl", new_vip, sizeof(vnode_impl_t));
+#endif
vcache_dealloc(new_vip);
vfs_unbusy(mp);
KASSERT(*vpp == NULL);
@@ -1390,6 +1403,9 @@ vcache_new(struct mount *mp, struct vnode *dvp, struct vattr *vap,
if (error)
return error;
vip = vcache_alloc();
+#ifdef LOCKDOC
+ lockdoc_log_memory(1, "vnode_impl", vip, sizeof(vnode_impl_t));
+#endif
vip->vi_key.vk_mount = mp;
vp = VIMPL_TO_VNODE(vip);
@@ -1398,6 +1414,9 @@ vcache_new(struct mount *mp, struct vnode *dvp, struct vattr *vap,
&vip->vi_key.vk_key_len, &vip->vi_key.vk_key);
if (error) {
mutex_enter(&vcache_lock);
+#ifdef LOCKDOC
+ lockdoc_log_memory(0, "vnode_impl", vip, sizeof(vnode_impl_t));
+#endif
vcache_dealloc(vip);
vfs_unbusy(mp);
KASSERT(*vpp == NULL);
@@ -1466,14 +1485,20 @@ vcache_rekey_enter(struct mount *mp, struct vnode *vp,
new_hash = vcache_hash(&new_vcache_key);
new_vip = vcache_alloc();
+#ifdef LOCKDOC
+ lockdoc_log_memory(1, "vnode_impl", new_vip, sizeof(vnode_impl_t));
+#endif
new_vip->vi_key = new_vcache_key;
/* Insert locked new node used as placeholder. */
mutex_enter(&vcache_lock);
vip = vcache_hash_lookup(&new_vcache_key, new_hash);
if (vip != NULL) {
+#ifdef LOCKDOC
+ lockdoc_log_memory(0, "vnode_impl", new_vip, sizeof(vnode_impl_t));
+#endif
vcache_dealloc(new_vip);
- return EEXIST;
+ return EEXIST;.()
}
SLIST_INSERT_HEAD(&vcache_hashtab[new_hash & vcache_hashmask],
new_vip, vi_hash);
@@ -1538,6 +1563,9 @@ vcache_rekey_exit(struct mount *mp, struct vnode *vp,
/* Remove new node used as placeholder. */
SLIST_REMOVE(&vcache_hashtab[new_hash & vcache_hashmask],
new_vip, vnode_impl, vi_hash);
+#ifdef LOCKDOC
+ lockdoc_log_memory(0, "vnode_impl", new_vip, sizeof(vnode_impl_t));
+#endif
vcache_dealloc(new_vip);
}