VHOLD(9)

πŸ’– VHOLD β€” ok so you wanna hold a vnode?? bestie same πŸ’–

Welcome to the VHOLD(9) page from the Kernel Developer's Manual, section 9 β€” the little corner of the manual where we talk about acquire/release a hold on a vnode. Yes queen, this is your group chat briefing. Let's get into it ✨


🌸 SYNOPSIS 🌸

First things first, you gotta bring the right headers to the party or nothing compiles, periodt:

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

Then the four besties themselves, all returning void because they're above returning things πŸ’…:

void
vhold(struct vnode *vp);

void
vholdl(struct vnode *vp);

void
vdrop(struct vnode *vp);

void
vdropl(struct vnode *vp);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the tea β˜•

The vhold() and vholdl() functions increment the v_holdcnt of the given vnode. That's it, that's the job, no cap. And if that vnode has already been added to the free list and is still referenced, it will be removed. So like… it was on the free list, but you said "no ma'am, we're still using this" and it gets pulled back off. Iconic behaviour honestly.

The vdrop() and vdropl() functions decrement the v_holdcnt of the vnode. Now listen, this is the part where you pay attention πŸ‘€ β€” if the holdcount is less than or equal to zero prior to calling vdrop() or vdropl(), the system will panic. Not a vibe. Not cute. A whole kernel panic. 😭 And if the vnode is no longer referenced, it will be freed.

And here's the lock lore, iykyk πŸ”’:

  • vhold() and vdrop() β€” these two lock the vnode interlock themselves. They handle it. They're the responsible ones.
  • vholdl() and vdropl() β€” these two expect the interlock to already be held. They're not locking anything for you, bestie. You show up with the lock already in hand or you don't show up at all. πŸ’…
✨ Quick mnemonic because I love you: the l at the end means "lock's already held, girl." No l = it locks for you. The more you know 🌈

πŸŽ€ SEE ALSO πŸŽ€

Go read your other bestie when you're done here:

  • vnode(9) β€” the whole vnode lore, the main character energy, the source material 🫢

πŸ‘‘ AUTHORS πŸ‘‘

This manual page was written by Chad David <davidc@acns.ab.ca>. We love a credited author, we stan, we give flowers πŸ’πŸŒΈ


Okay that's the whole page, you're officially a vnode-holding expert now, go forth and do not panic the kernel, I believe in you fr fr πŸ’œ

This came to you from the Debian crew, dated April 1, 2007, filed under VHOLD(9) β€” mwah, take care of yourself and your reference counts πŸ§šβœ¨πŸ’–

πŸ“¦ where this page comes from