VOP_GETPAGES(9)
π VOP_GETPAGES β read or write VM pages from a file π
okay bestie, gather round, because this is the <hotpink>kernel developer's manual</hotpink> page for VOP_GETPAGES(9) and honestly? it's giving main character energy in the vnode layer. π¦
β¨ NAME β¨
VOP_GETPAGES, VOP_PUTPAGES β read or write VM pages from a file
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <sys/vnode.h>
#include <vm/vm.h>
int
VOP_GETPAGES(struct vnode *vp, vm_page_t *ma, int count, int *rbehind,
int *rahead);
int
VOP_PUTPAGES(struct vnode *vp, vm_page_t *ma, int bytecount, int flags,
int *rtvals);
π DESCRIPTION π
So, VOP_GETPAGES() is the method you call when you wanna read in pages of virtual memory that are backed by ordinary files. And if there are other adjacent pages backed by adjacent regions of the same file? Then VOP_GETPAGES() gets asked to read those too β although, lowkey, it is not required to do so. π«Ά
VOP_PUTPAGES() does the converse, iykyk β it writes out adjacent dirty pages of virtual memory. π§
On entry, the vnode lock is held, but neither the page queue nor VM object locks are held. Both methods return in the same state on both success and error returns. No cap. π―
The arguments are:
vpβ The file to access.maβ Pointer to the first element of an array of pages representing a contiguous region of the file to be read or written.countβ The length of themaarray.bytecountβ The number of bytes that should be written from the pages of the array.flagsβ A bitfield of flags affecting the function operation.- If
VM_PAGER_PUT_SYNCis set, the write should be synchronous; control must not be returned to the caller until after the write is finished. like, it is NOT done until it is DONE, periodt. - If
VM_PAGER_PUT_INVALis set, the pages are to be invalidated after being written. - If
VM_PAGER_PUT_NOREUSEis set, the I/O performed should set theIO_NOREUSEflag, to indicate to the filesystem that pages should be marked for fast reuse if needed. This could occur via a call tovm_page_deactivate_noreuse(9), which puts such pages onto the head of the inactive queue. π - If
VM_PAGER_CLUSTER_OKis set, writes may be delayed, so that related writes can be coalesced for efficiency, e.g., using the clustering mechanism of the buffer cache. β¨ efficiency queen β¨
- If
rtvalsβ An array of VM system result codes indicating the status of each page written byVOP_PUTPAGES().rbehindβ Optional pointer to integer specifying number of pages to be read behind, if possible. If the filesystem supports that feature, number of actually read pages is reported back, otherwise zero is returned.raheadβ Optional pointer to integer specifying number of pages to be read ahead, if possible. If the filesystem supports that feature, number of actually read pages is reported back, otherwise zero is returned.
π the page-by-page receipts π
The status of the VOP_PUTPAGES() method is returned on a page-by-page basis in the array rtvals[]. The possible status values are as follows:
VM_PAGER_OKβ The page was successfully written. The implementation must callvm_page_undirty(9)to mark the page as clean. ate, no crumbs. πVM_PAGER_PENDβ The page was scheduled to be written asynchronously. When the write completes, the completion callback should callvm_object_pip_wakeup(9)andvm_page_sunbusy(9)to clear the busy flag and awaken any other threads waiting for this page, in addition to callingvm_page_undirty(9).VM_PAGER_BADβ The page was entirely beyond the end of the backing file. This condition should not be possible if the vnode's file system is correctly implemented. πVM_PAGER_ERRORβ The page could not be written because of an error on the underlying storage medium or protocol.VM_PAGER_FAILβ Treated identically toVM_PAGER_ERROR.VM_PAGER_AGAINβ The page was not handled by this request.
π¦ the getpages rules, listen up π¦
The VOP_GETPAGES() method must populate and validate all requested pages in order to return success. It is expected to release any pages in ma that it does not successfully handle, by calling vm_page_free(9). When it succeeds, VOP_GETPAGES() must set the valid bits appropriately.
Upon entry to VOP_GETPAGES(), all pages in ma are busied exclusively. Upon successful return, the pages must all be busied exclusively as well, but pages may be unbusied during processing. The filesystem is responsible for activating paged-out pages, but this does not necessarily need to be done within VOP_GETPAGES() depending on the architecture of the particular filesystem. π§ β¨
π RETURN VALUES π
If it successfully reads all pages in ma, VOP_GETPAGES() returns VM_PAGER_OK; otherwise, it returns VM_PAGER_ERROR. By convention, the return value of VOP_PUTPAGES() is rtvals[0]. π
π SEE ALSO π
vm_object_pip_wakeup(9), vm_page_free(9), vm_page_sunbusy(9), vm_page_undirty(9), vm_page_xunbusy(9), vnode(9)
π AUTHORS π
This manual page was written by Doug Rabson and then substantially rewritten by Garrett Wollman. icons, both of them. π
and that's the whole vibe check, bestie β this one's from the Debian crew, dated June 29, 2019, and it says VOP_GETPAGES(9) at the top and bottom because it simply cannot stop being iconic. slay, go free your pages. π
β¨π«Ά
π¦ 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) 1996 Doug Rabson
- Copyright 2003, Garrett A. Wollman
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms