VHOLD(9)

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

🌸 VHOLD(9) β€” the Kernel Developer's Manual, but make it make sense 🌸

okay bestie, welcome to section 9 of the Kernel Developer's Manual β€” you're in the big-kid kernel-functions part now, and today's episode is all about getting and releasing a hold on a vnode. yes. that's the whole vibe. let's go πŸ’…

✨ NAME ✨

vhold, vdrop, vdropl β€” acquire/release a hold on a vnode

(yes, the NAME line says exactly those three β€” vhold, vdrop, vdropl β€” and we are not editing it, we are respecting it 🫢 vholdl shows up in the synopsis below, don't worry, she's there too.)


✨ SYNOPSIS ✨

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

void
vhold(struct vnode *vp);

void
vholdl(struct vnode *vp);

void
vdrop(struct vnode *vp);

void
vdropl(struct vnode *vp);

four little functions, all void, all taking a struct vnode *vp, all iconic in their own way πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

so. vhold() and vholdl() β€” these two cuties increment the v_holdcnt of the vnode you hand them. and like, plot twist: if that vnode has already been added to the free list and is still referenced, it gets removed from there. say bye πŸ‘‹

meanwhile vdrop() and vdropl() are the opposite girlies β€” they decrement the v_holdcnt of the vnode. and if the holdcount is less than or equal to zero before you call vdrop() or vdropl()...

🚨 the system will panic. like, full-on. not a vibe check, an actual panic. do not let v_holdcnt hit zero-or-below before you drop. periodt. πŸ’€

and if the vnode is no longer referenced? it gets freed. clean. gone. released into the void πŸ¦‹

now the locking tea β˜• β€” because this is the part everyone forgets:

  • vhold() and vdrop() lock the vnode interlock for you. they handle it. main character energy, they've got it covered.
  • vholdl() and vdropl() expect the interlock to already be held</> when you call them. so if you didn't lock it first, that's on you, bestie 😭

iykyk β€” the trailing l is the "locked already" one. no cap.


🌈 SEE ALSO 🌈

  • vnode(9) β€” go read it, she's the whole ecosystem 🧚

πŸŽ€ AUTHORS πŸŽ€

This manual page was written by Chad David <davidc@acns.ab.ca>. thank you Chad, king behavior πŸ‘‘βœ¨


and that's the page!! πŸ“ this beauty shipped with Debian and is dated April 1, 2007 β€” so if the panic warning felt like a joke, it is NOT, it's from 2007 and it's still real πŸ’œ mwah, go hold some vnodes responsibly 🫢

πŸ“¦ where this page comes from