summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerlin Scholz <merlin@scholz.ruhr>2023-05-29 00:37:34 +0200
committerMerlin Scholz <merlin@scholz.ruhr>2023-07-11 01:38:02 +0200
commitc1fceea221da368626bc72cccc32684c6716ede3 (patch)
tree104cb869587a02549b2d791e2f285e079f09a4d1
parent852be4b1cf5425659bac910a9e03b092aca5c4ca (diff)
Organize VFS logging
-rw-r--r--sys/kern/vfs_vnode.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/sys/kern/vfs_vnode.c b/sys/kern/vfs_vnode.c
index 2446f483e26..2ae94366266 100644
--- a/sys/kern/vfs_vnode.c
+++ b/sys/kern/vfs_vnode.c
@@ -1312,6 +1312,11 @@ vcache_init(void)
vcache_hashtab = hashinit(desiredvnodes, HASH_SLIST, true,
&vcache_hashmask);
hashstat_register("vcache", vcache_stats);
+
+#ifdef LOCKDOC
+ // TODO
+ //lockdoc_log_memory(1, "hashhead", vcache_hashtab, sizeof(*vcache_hashtab));
+#endif
}
static void
@@ -1393,6 +1398,10 @@ vcache_alloc(void)
lru_requeue(vp, &lru_list[LRU_FREE]);
+#ifdef LOCKDOC
+ lockdoc_log_memory(1, "vnode_impl", vip, sizeof(*vip));
+#endif
+
return vip;
}
@@ -1415,6 +1424,11 @@ vcache_dealloc(vnode_impl_t *vip)
vp->v_op = dead_vnodeop_p;
VSTATE_CHANGE(vp, VS_LOADING, VS_RECLAIMED);
mutex_exit(&vcache_lock);
+
+ /*
+ * LOCKDOC: No log_memory here, since vrelel calls
+ * vcache_free or vcache_reclaim at some point
+ */
vrelel(vp, 0, LK_NONE);
}
@@ -1448,6 +1462,10 @@ vcache_free(vnode_impl_t *vip)
cv_destroy(&vp->v_cv);
cache_vnode_fini(vp);
pool_cache_put(vcache_pool, vip);
+
+#ifdef LOCKDOC
+ lockdoc_log_memory(0, "vnode_impl", vip, sizeof(*vip));
+#endif
}
/*
@@ -1568,9 +1586,6 @@ again:
if (error)
return error;
new_vip = vcache_alloc();
-#ifdef LOCKDOC
- lockdoc_log_memory(1, "vnode_impl", new_vip, sizeof(*new_vip));
-#endif
new_vip->vi_key = vcache_key;
vp = VIMPL_TO_VNODE(new_vip);
mutex_enter(&vcache_lock);
@@ -1583,9 +1598,6 @@ 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(*new_vip));
-#endif
vcache_dealloc(new_vip);
vfs_unbusy(mp);
goto again;
@@ -1598,9 +1610,6 @@ 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(*new_vip));
-#endif
vcache_dealloc(new_vip);
vfs_unbusy(mp);
KASSERT(*vpp == NULL);
@@ -1645,9 +1654,6 @@ 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(*vip));
-#endif
vip->vi_key.vk_mount = mp;
vp = VIMPL_TO_VNODE(vip);
@@ -1656,9 +1662,6 @@ 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(*vip));
-#endif
vcache_dealloc(vip);
vfs_unbusy(mp);
KASSERT(*vpp == NULL);
@@ -1727,18 +1730,12 @@ 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(*new_vip));
-#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(*new_vip));
-#endif
vcache_dealloc(new_vip);
return EEXIST;
}
@@ -1805,9 +1802,6 @@ 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(*new_vip));
-#endif
vcache_dealloc(new_vip);
}
@@ -1817,6 +1811,11 @@ vcache_rekey_exit(struct mount *mp, struct vnode *vp,
* Must be called with vnode locked and will return unlocked.
* Must be called with the interlock held, and will return with it held.
*/
+/*
+ * LOCKDOC: All functions called by vcache_reclaim are blacklisted in the
+ * LOCKDOC experiments since all references to the data structure
+ * are made obsolete manually (rather than precventing access through locks)
+ */
static void
vcache_reclaim(vnode_t *vp)
{
@@ -1939,7 +1938,7 @@ vcache_reclaim(vnode_t *vp)
VSTATE_CHANGE(vp, VS_RECLAIMING, VS_RECLAIMED);
vp->v_tag = VT_NON;
mutex_exit(vp->v_interlock);
-
+
/*
* Move to dead mount. Must be after changing the operations
* vector as vnode operations enter the mount before using the
@@ -1956,6 +1955,10 @@ vcache_reclaim(vnode_t *vp)
mutex_enter(vp->v_interlock);
fstrans_done(mp);
KASSERT((vp->v_iflag & VI_ONWORKLST) == 0);
+
+#ifdef LOCKDOC
+ lockdoc_log_memory(0, "vnode_impl", vip, sizeof(*vip));
+#endif
}
/*