INSMNTQUE(9)

πŸ’– INSMNTQUE β€” associate a vnode with a mount πŸ’–

okay bestie, welcome to the insmntque page, from section 9 of the kernel developer's manual. this is the one where we marry a vnode to a mount. it's giving matchmaker energy fr fr. πŸŽ€


✨ NAME ✨

insmntque, insmntque1 β€” associate a vnode with a mount


🌸 SYNOPSIS 🌸

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

int
insmntque(struct vnode *vp, struct mount *mp);

int
insmntque1(struct vnode *vp, struct mount *mp,
    void (*dtr)(struct vnode *, void *), void *dtr_arg);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, the insmntque() function associates a vnode with a mount. that's the whole vibe. ✨ and it's not just setting a lil pointer, bestie β€” it's doing a whole lil ceremony:

  • it updates v_mount for the vnode
  • and it inserts the vnode into the mount's vnode list

the mount reference count gets incremented for every vnode added to the mount, and that reference is decremented by vgone(9). so like, every time you add one, the mount's refcount goes up, and vgone(9) is the one that lets it back down. no cap. πŸ’…

the mount's interlock is held while the vnode is inserted. and for MP-safe file systems? the vnode must be exclusively locked. that's not optional, that's the rules. πŸ”’


😭 when it goes wrong (the failure arc) 😭

on failure, insmntque() calls vgone(9) on the supplied vnode, and then it drops the vnode lock and reference. that's just what it does, it's built different.

but like… what if you need more elaborate cleanup after an insmntque() failure? πŸ™ˆ that's literally why insmntque1() exists, bestie. it's the glow-up version. here's the tea:

  • the dtr argument is a pointer to a function that gets called on failure
  • that function may perform any custom cleanup you need. go off, it's your moment. πŸ‘‘
  • the vnode pointer is supplied as the first argument to dtr
  • the dtr_arg argument is the second one, supplying any additional context needed

so yeah, insmntque1() lets you do your own lil cleanup ritual instead of the default one. iconic.


⭐ RETURN VALUES ⭐

the insmntque() function will always return 0… unless the file system is currently being unmounted, in which case it may return EBUSY. 😭

also!! insmntque() may be forced to insert the vnode into the mount's vnode list by setting the VV_FORCEINSMQ flag in the vnode v_flag β€” even if the file system is being unmounted. so like, you can override the vibe check if you really want to. slay, but carefully. πŸ’€

🌈 SEE ALSO 🌈


πŸ’œ AUTHORS πŸ’œ

this manual page was written by Chad David <davidc@acns.ab.ca>. thank you chad, you ate. 🫢


and that's the whole page bestie!! πŸŽ€βœ¨ this one came from Debian, dated September 8, 2008 β€” so it's older than most of the group chat but it's still serving. go forth and associate those vnodes. mwah. πŸ’…πŸŒΈ

πŸ“¦ where this page comes from