VREF(9)

πŸ’– VREF πŸ’–

okay bestie, welcome to section 9 of the Kernel Developer's Manual β€” that's the kernel interface girlies, the deep magic 🧚✨. Today's episode: vref and vrefl, aka the two functions that make your vnode's use count go up by one. no cap.


✨ NAME ✨

vref, vrefl β€” increment the use count for a vnode πŸ¦‹


🌸 SYNOPSIS 🌸

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

void
vref(struct vnode *vp);

void
vrefl(struct vnode *vp);

πŸ’… DESCRIPTION πŸ’…

So what are we even doing here? We are incrementing the v_usecount field of a vnode. that's it. that's the whole job. and honestly? iconic behavior.

  • vp β€” the vnode to increment πŸŽ€

Every vnode out here keeps a reference count of how many parts of the system are using it. think of it like a group chat member count, but for kernel objects. this is the mechanism that lets the system clock when a vnode is no longer being used, so it can be safely recycled for a different file. slay. β™»οΈβœ¨

Any code in the system that's using a vnode β€” like, during the operation of some algorithm, or because it's storing the vnode in a data structure β€” should call vref() or vrefl(). like, if you're holding a vnode, you hold a reference. that's the vibe. that's the whole social contract. 🫢

Now here's the plot twist, and it's giving main character energy for real:

  • vref() locks the vnode interlock all by itself πŸ’…
  • vrefl() expects the interlock to already be held β€” so don't you dare call it without it 😭
fr fr, pick the right one. if you already got the interlock, use vrefl(). if you don't, use vref(). don't mix them up, bestie, the kernel will notice. πŸ’€

🌈 SEE ALSO 🌈

go read those next, iykyk πŸ“šβœ¨


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Doug Rabson. thank you for your service, king πŸ«‘πŸ’–


and that's the whole page, babes!! this lil writeup came from the Debian edition, dated January 18, 2016, filed under VREF(9) in the Kernel Developer's Manual. go forth and increment responsibly πŸŒΈπŸ’œπŸ¦‹

πŸ“¦ where this page comes from