---
name: "VOP_PUTPAGES"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/VOP_PUTPAGES"
---

# VOP\_PUTPAGES(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 \*m*, *int count*, *int reqpage*, *vm\_ooffset\_t offset*);

*int*\

**VOP\_PUTPAGES**(*struct vnode \*vp*, *vm\_page\_t \*m*, *int count*, *int sync*, *int \*rtvals*, *vm\_ooffset\_t offset*);

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

- *m*

  Pointer to the first element of an array of contiguous pages representing a contiguous region of the file to be read or written.

- *count*

  The number of pages in the array.

- *sync*

  VM\_PAGER\_PUT\_SYNC if the write should be synchronous.

- *rtvals*

  An array of VM system result codes indicating the status of each page written by **VOP\_PUTPAGES**().

- *reqpage*

  The index in the page array of the requested page; i.e., the one page which the implementation of this method must handle.

- *offset*

  Offset in the file at which the mapped pages begin.

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\_io\_finish(9)](/vm_page_io_finish/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 is expected to release any pages in *m* 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, clear the dirty bit (using [vm\_page\_undirty(9)](/vm_page_undirty/9.md)), either activate the page (if its wanted bit is set) or deactivate it (otherwise), and finally call [vm\_page\_wakeup(9)](/vm_page_wakeup/9.md) to arouse any threads currently waiting for the page to be faulted in, for each page read.

## RETURN VALUES

If it successfully reads *m\[reqpage\]*, **VOP\_GETPAGES**() returns VM\_PAGER\_OK; otherwise, 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\_io\_finish(9)](/vm_page_io_finish/9.md), [vm\_page\_undirty(9)](/vm_page_undirty/9.md), [vm\_page\_wakeup(9)](/vm_page_wakeup/9.md), [vnode(9)](/vnode/9.md)

## AUTHORS

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