VNODE_PAGER_SETSIZE(9)
π VNODE_PAGER_SETSIZE(9) β like, the kernel dev manual page, bestie
okay so picture this: you're deep in kernel-land, and the VM system has no idea your file just changed size. rude. that's literally what vnode_pager_setsize is for β¨
πΈ NAME πΈ
vnode_pager_setsize β the function that tells the VM system "hey bestie, the file size changed" π
π SYNOPSIS π
#include <sys/param.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
void
vnode_pager_setsize(struct vnode *vp, vm_ooffset_t nsize);
π¦ DESCRIPTION π¦
vnode_pager_setsize lets the VM system know that a file's size changed, and it updates both the object size and the vnode pager size of the vm object in vp to match nsize. so iconic of it π«Ά
now the serious part, no cap: if you get a page fault on the object mapping with an offset that's past the new object size, that fault results in SIGBUS. literally not the vibe. π
when the file size shrinks, the pages between the old EOF and the new EOF get removed from the object queue. and if the new EOF you passed in nsize isn't aligned to a page boundary? then the partial-page area starting beyond the EOF gets zeroed out and marked invalid β but only if that page actually exists resident. yes, there's a vibe check involved π§
also important: if the vnode vp doesn't have a VM object allocated, calling this function is a no-op. nothing happens. it simply said "not today" π
this function must be used inside file system code to implement truncation, if your file system allocates vm objects for vnodes. periodt. π
π LOCKS π
the vnode should be exclusively locked on entry, and it will still be locked on exit. it's giving "you had one job and you kept it" energy π
π SEE ALSO π
β HISTORY β
the vnode_pager_setsize manual page first appeared in FreeBSD 14. a whole era π₯
π AUTHORS π
this manual page was written by Ka Ho Ng <khng@FreeBSD.org>. thank you for your service π«‘ π
fr fr, keep that vnode locked and your pages aligned, bestie β the VM system is watching π
okay that's the whole thing, mwah π this was Debian, dated April 8, 2021, and yes that's the same VNODE_PAGER_SETSIZE(9) we started with β slay, go update some file sizes β¨π·
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- π the page's license: BSD-2-Clause
- Copyright (c) 2021 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms