VREF(9)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… VREF(9) β€” like, the vnode reference counter manual, bestie

okay so this is a page from the Kernel Developer's Manual (that's the manual name, iykyk πŸŽ€) and honestly it's short but it matters, so let's get into it ✨


✨ NAME ✨

vref, vrefl β€” increment the use count for a vnode

like literally that's the whole job. bumping the counter. no cap. πŸ’…


🌸 SYNOPSIS 🌸

#include <sys/param.h>
#include <sys/vnode.h>

void
vref(struct vnode *vp);

void
vrefl(struct vnode *vp);

two functions, both void, both take a struct vnode *vp, both return nothing because they're too busy slaying πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

So bestie, the tea is: these functions increment the v_usecount field of a vnode. That's it. That's the whole vibe check. ✨

  • vp β€” the vnode to increment 🫢

okay but why do we care, right? because every single vnode keeps a reference count of how many parts of the system are using it. think of it as a little tally of everyone who's currently obsessed with that vnode πŸ’€ and the whole point is that this lets the system detect when a vnode is no longer being used β€” and once nobody's using it, it can be safely recycled for a different file. so it's giving responsible resource management, main character energy for the kernel πŸ”₯

the rule, fr fr: any code in the system which is using a vnode (like, during the operation of some algorithm, or to store in a data structure) should call vref() or vrefl(). no excuses, no skipping, periodt πŸ‘‘

and here's the difference between the two, pay attention because this is the part people mess up πŸ™ˆ

  • vref() locks the vnode interlock while it does its thing
  • vrefl() expects the interlock to already be held β€” so like, it's on you, you better already have it 😭
so if you call vrefl() without already holding the interlock, that's a you problem, not a vrefl() problem. pick the right one, bestie πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

the whole vnode friend group, go read them too, they all ate 🌈


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Doug Rabson. iconic behaviour honestly, thank you Doug 🫢


and that's the page!! this version came to you from Debian, dated January 18, 2016, filed under VREF(9) β€” mwah, go increment some counters responsibly bestie πŸ’œβœ¨

πŸ“¦ where this page comes from