From: "Ted Unangst" Subject: Re: Trying to understand vnode refcounting To: "Martin Yoffe" Cc: tech@openbsd.org Date: Thu, 15 May 2025 17:11:28 -0400 On 2025-05-15, Martin Yoffe wrote: > 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. When VOP_MKDIR says dvp is unlocked on exit, that means it called vput which will drop the use count, too.