---
name: "VOP_GETPAGES"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/VOP_GETPAGES"
---

# VOP\_GETPAGES(9)

read or write VM pages from a file

## 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

The **VOP\_GETPAGES**() method is called to read in pages of virtual memory which are backed by ordinary files. If other adjacent pages are backed by adjacent regions of the same file, **VOP\_GETPAGES**() is requested to read those pages as well, although it is not required to do so. The **VOP\_PUTPAGES**() method does the converse; that is to say, 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.

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 the *ma* array.

- *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\_SYNC is set, the write should be synchronous; control must not be returned to the caller until after the write is finished. If VM\_PAGER\_PUT\_INVAL is set, the pages are to be invalidated after being written. If VM\_PAGER\_PUT\_NOREUSE is set, the I/O performed should set the IO\_NOREUSE flag, to indicate to the filesystem that pages should be marked for fast reuse if needed. This could occur via a call to vm\_page\_deactivate\_noreuse(9), which puts such pages onto the head of the inactive queue. If VM\_PAGER\_CLUSTER\_OK is set, writes may be delayed, so that related writes can be coalesced for efficiency, e.g., using the clustering mechanism of the buffer cache.

- *rtvals*

  An array of VM system result codes indicating the status of each page written by **VOP\_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 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 call [vm\_page\_undirty(9)](/vm_page_undirty/9.md) to mark the page as clean.

- VM\_PAGER\_PEND

  The page was scheduled to be written asynchronously. When the write completes, the completion callback should call vm\_object\_pip\_wakeup(9) and [vm\_page\_sunbusy(9)](/vm_page_sunbusy/9.md) to clear the busy flag and awaken any other threads waiting for this page, in addition to calling [vm\_page\_undirty(9)](/vm_page_undirty/9.md).

- 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 to VM\_PAGER\_ERROR.

- VM\_PAGER\_AGAIN

  The page was not handled by this request.

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)](/vm_page_free/9.md). 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_free/9.md), [vm\_page\_sunbusy(9)](/vm_page_sunbusy/9.md), [vm\_page\_undirty(9)](/vm_page_undirty/9.md), [vm\_page\_xunbusy(9)](/vm_page_xunbusy/9.md), [vnode(9)](/vnode/9.md)

## AUTHORS

This manual page was written by Doug Rabson and then substantially rewritten by Garrett Wollman.
