VOP_INACTIVE(9)

VOP_INACTIVE πŸ’– (section 9 of the Kernel Developer's Manual, bestie)

okay so welcome to the vnode-recycling corner of the kernel, where we give file system resources back and say bye to vnodes that are done being useful πŸŽ€ this page covers VOP_INACTIVE and VOP_RECLAIM, and together they're giving "reclaim file system resources for a vnode" energy ✨


✨ NAME ✨

VOP_INACTIVE, VOP_RECLAIM β€” reclaim file system resources for a vnode 🧚


🌸 SYNOPSIS 🌸

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

int
VOP_INACTIVE(struct vnode *vp, struct thread *td);

int
VOP_RECLAIM(struct vnode *vp, struct thread *td);

πŸ’… DESCRIPTION πŸ’…

The arguments are:

  • vp β€” the vnode being reclaimed. that's the one, that's our girl πŸ’–

VOP_INACTIVE() is usually called when the kernel is no longer using the vnode. usually, bestie, because β€” and this is the important part β€” there is no guarantee that it will be called at all. for example if the last reference was dropped while the vnode lock could not be upgraded to exclusive without sleeping. 😭

why might it fire? could be that the reference count reaches zero, or it could be that the file system is being forcibly unmounted while there are open files. either way, it's useful for reclaiming space on the last close of an 'open but deleted' file πŸ—‘οΈβœ¨

VOP_RECLAIM() is called when a vnode is being reused for a different file system. any file system specific resources associated with the vnode should be freed. like, actually freed, that's your job, don't ghost them πŸ‘‘ periodt.


πŸ”’ LOCKS πŸ”’

for both VOP_INACTIVE() and VOP_RECLAIM(): the vp will be exclusively locked on entry, and it must be left exclusively locked on return. no cap, don't you dare unlock it on the way out πŸ’…


πŸ‘€ SEE ALSO πŸ‘€


🫢 AUTHORS 🫢

this manual page was written by Doug Rabson. iconic of him fr fr 🌟


and that's the whole page, bestie πŸ¦‹ this one came from the Debian crew β€” dated March 15, 2019 β€” and it lives under VOP_INACTIVE(9) in the Kernel Developer's Manual. go forth and free those vnode resources, you absolute main character πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from