VRELE(9)

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

πŸ’… VRELE(9) β€” the kernel dev manual, bestie edition πŸŽ€

okay so this is the page for vput, vrele, and vunref β€” the three little gremlins that all do the same vibe: decrement the use count for a vnode. yes they're from the Kernel Developer's Manual, and yes they're lowkey iconic.


✨ NAME ✨

vput, vrele, vunref β€” decrement the use count for a vnode


🌸 SYNOPSIS 🌸

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

void
vput(struct vnode *vp);

void
vrele(struct vnode *vp);

void
vunref(struct vnode *vp);

πŸ¦‹ DESCRIPTION πŸ¦‹

So the whole entire job of these three is: decrement the v_usecount field of a vnode. that's it. that's the post. πŸ’…

Here's the one argument you're gonna be passing around like it's the aux cord:

  • vp β€” the vnode to decrement

Now let's meet the trio, because they are not the same girlies even though they look alike:

  • vrele() β€” takes an unlocked vnode, and returns with the vnode unlocked. so it goes in chill and comes out chill. no cap.
  • vput() β€” should be given a locked vnode as its argument, and the vnode is unlocked after the function returns. and here's the tea πŸ‘€ β€” vput() is operationally equivalent to calling VOP_UNLOCK(9) followed by vrele(), just with less overhead. so it's the same fit, but snatched and efficient.
  • vunref() β€” takes a locked vnode as its argument, and returns with the vnode locked. goes in locked, comes out locked. consistency queen.

Any code in the system which signified its use of a vnode by usecount should call one of the listed function to decrement use counter. like, that's the whole point. If the v_usecount field of the non-doomed vnode reaches zero, then it will be inactivated and placed on the free list. bye bestie, off to the free list you go 🫢

Heads up though β€” the vrele() function may lock the vnode. And all three functions may sleep. so don't be out here calling them in places where sleeping is illegal, that's not the vibe 😭

The hold count for the vnode is always greater or equal to the usecount. fr fr, always. And non-forced unmount fails when a mount point owns a vnode that has a non-zero usecount β€” see vflush(9). so if your unmount is acting up, check your usecounts, that's the main character energy you're looking for πŸ’€


πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Doug Rabson and Konstantin Belousov. absolute legends, we stan πŸ’–


and that's the page!! go forth and decrement responsibly, bestie. this lil beauty came to you from Debian, dated February 24, 2016 β€” vintage but still slaying βœ¨πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from