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, usevrefl(). if you don't, usevref(). 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
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1996 Doug Rabson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms