VINVALBUF(9)
π VINVALBUF β the vinvalbuf(9) era π
okay bestie, gather round, because we're talking about a Kernel Developer's Manual page today and it's lowkey iconic. This is vinvalbuf(9), and it's giving "clean slate" energy in the purest way possible.
β¨ NAME β¨
vinvalbuf β flushes and invalidates all buffers associated with a vnode πΈ
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <sys/vnode.h>
int
vinvalbuf(struct vnode *vp, int flags, struct ucred *cred, int slpflag,
int slptimeo);
β¨ DESCRIPTION β¨
so the vinvalbuf() function literally invalidates all of the buffers associated with the given vnode. all of them. every last one. it's giving spring cleaning π§Ήβ¨
and bestie, that includes buffers on the clean list and the dirty list. both. no crumbs left.
if the V_SAVE flag is specified, then the buffers on the dirty list get synced prior to being released β so like, they get one last little goodbye kiss before they go π
and if there's a VM Object associated with the vnode? yeah, it's removed. gone. not me being dramatic, that's just what it does.
π Its arguments are π
vpβ a pointer to the vnode whose buffers will be invalidated. this is the main character of the whole operation honestly.flagsβ the only supported flag isV_SAVE, and it indicates that dirty buffers should be synced with the disk. just the one flag. that's the whole menu. don't come looking for more.credβ the user credentials that are used toVOP_FSYNC(9)buffers ifV_SAVEis set. yes, credentials. we're doing this properly.slpflagβ the slp flag that will be used in the priority of any sleeps in the function. the vibe of the nap, if you will π΄slptimeoβ the timeout for any sleeps in the function. how long the nap can last before we're like "okay bestie wake up" β°
π LOCKS π
the vnode is assumed to be locked prior to the call and remains locked upon return. so like, it goes in locked, it comes out locked. the lock never left the group chat π
Giant must be held prior to the call and remains locked upon return. same deal, different lock. giant stays held, periodt.
β¨ RETURN VALUES β¨
a 0 value is returned on success. that's it. that's the whole success story. 0 = we ate π½οΈπ
π PSEUDOCODE π
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = vinvalbuf(devvp, V_SAVE, cred, 0, 0);
VOP_UNLOCK(devvp, 0);
if (error)
return (error);
look at that flow. lock it, invalidate it, unlock it, and if anything went sideways, we bounce out with the error. clean. iconic. no notes π
π ERRORS π
[ENOSPC]β the file system is full. (withV_SAVE) π[EDQUOT]β disk quota exceeded. (withV_SAVE) π[EWOULDBLOCK]β sleep operation timed out. (seeslptimeo) β°[ERESTART]β a signal needs to be delivered and the system call should be restarted. (withPCATCHset inslpflag)[EINTR]β the system has been interrupted by a signal. (withPCATCHset inslpflag)
π SEE ALSO π
like, go read those too, they're part of the lore, iykyk π¦
π«Ά AUTHORS π«Ά
this manual page was written by Chad David <davidc@acns.ab.ca>. we love a credited author, truly π
and that's the whole page bestie!! this one came from the Debian distribution, dated October 20, 2008 β yes, 2008, a vintage, an absolute classic, and honestly it still serves. go forth and invalidate those buffers, you've got this πβ¨π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms