Download raw body.
Trying to understand vnode refcounting
Hi tech@, Lately I've been trying to port nullfs from 4.4BSD-Lite2 back to OpenBSD. 4.4BSD used `struct vnodeopv_*` to store and handle vnode operations, while we have `struct vops`, so I'm translating each operation one by one. Most of them are just calling the aliased vnode's VOP_* operation, some are a bit trickier. One thing I've been struggling with is vnode reference counting. When syscalls call VOP_* on nullfs vnodes, their handling of refcounting is not automatically passed through to the aliased vnodes, so we have to replicate the behavior they expect before and after calling VOP_* in each nullfs vop (in 4.4BSD, how each operation handles refcounting is stored in the vnodeopv_* structures so this can be done automatically, but obviously we can't do that). At first I looked at VOP_LOOKUP(9) that describes how vnodes' refcounting should be handled before and after calling each operation. Then, out of curiosity, I tried to print some v_usecounts before and after calling VOP_* operations inside syscalls (on a ufs), and found some discrepancies with the information in VOP_LOOKUP(9). For example, the call to VOP_MKDIR in domkdirat (sys/kern/vfs_syscalls.c) decrements its dvp's v_usecount, which is not mentionned in the man page. Even weirder, when doing the same thing for the VOP_LOOKUP call inside vfs_lookup (sys/kern/vfs_lookup.c), sometimes dp's v_usecount is decremented, sometimes it stays the same. So I was wondering, is the man page up-to-date? If not, should I test every VOP_* call inside syscalls and fix the docs? Also, does someone understand how VOP_LOOKUP should handle refcounting? Thanks
Trying to understand vnode refcounting