VRELE(9)

πŸ’– VRELE(9) β€” vput, vrele, vunref πŸ’–

okay bestie, come sit with me, we're talking about the Kernel Developer's Manual today and honestly? this one is a whole vibe. we're out here decrementing use counts on vnodes and it's giving very much "responsible resource management era" ✨


🌸 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);

like yes, three little functions, all returning void, all taking a struct vnode *vp. no cap, that's the whole signature situation πŸŽ€


πŸ’… DESCRIPTION πŸ’…

So the tea is: these functions decrement the v_usecount field of a vnode. That's it. That's the job. 😌

  • vp β€” the vnode to decrement πŸ’œ

Okay now let's get into the specifics because each one of these girlies has her own personality:

  • The vrele() function takes an unlocked vnode and returns with the vnode unlocked. She doesn't touch the lock, she just does her little count decrement and leaves. Lowkey the chill one 🧚
  • The vput() function should be given a locked vnode as argument, and the vnode is unlocked after the function returns. And here's the iconic part: vput() is operationally equivalent to calling VOP_UNLOCK(9) followed by vrele(9), with less overhead. It's literally the same thing but faster, iykyk πŸ”₯
  • The vunref() function takes a locked vnode as argument, and returns with the vnode still locked. She holds on. She's not letting go. Main character energy fr πŸ‘‘

Any code in the system which signified its use of a vnode by usecount should call one of the listed functions to decrement the use counter. If the v_usecount field of the non-doomed vnode reaches zero, then it will be inactivated and placed on the free list. so like, when the count hits zero it's not gone-gone, it just goes to sit on the free list until someone needs it again. recycling era ♻️

Heads up bestie: the vrele() function may lock the vnode. And all three functions may sleep. So like, don't call these while holding something spicy, okay? 😭

Also important: the hold count for the vnode is always greater or equal to the usecount. And non-forced unmount fails when a mount point owns a vnode that has non-zero usecount β€” see vflush(9). So yeah, if you're trying to unmount nicely and something's still holding a usecount, it's not happening. Periodt. πŸ’€


πŸ¦‹ SEE ALSO πŸ¦‹

go read these next, they're all part of the same little friend group 🌈


πŸ‘‘ AUTHORS πŸ‘‘

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


and that's the whole page bestie!! this was the VRELE(9) page from the Debian crew, dated February 24, 2016 β€” go forth and decrement responsibly, mwah πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from