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

# VOP\_READ\_PGCACHE(9)

read a file, fast

## NAME

**VOP\_READ\_PGCACHE** – read a file, fast

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/vnode.h\>**

**#include \<sys/uio.h\>**

*int*\

**VOP\_READ\_PGCACHE**(*struct vnode \*vp*, *struct uio \*uio*, *int ioflag*, *struct ucred \*cred*);

## DESCRIPTION

This entry point reads the contents of a file. The intent is to provide the data from caches, which do not require expensive operations or any disk IO. For instance, if filesystem uses normal VM page cache and maintains v\_object lifetime, it can use vn\_read\_from\_obj(9) helper to return data from the resident vp-\>v\_object pages.

The filesystem indicates support for the **VOP\_READ\_PGCACHE** on specific vnode by setting the VIRF\_PGREAD flag in vp-\>v\_irflag.

The function does not need to satisfy the whole request; it also might choose to not provide any data. In these cases, the *uio* must be advanced by the amount of read data, **VOP\_READ\_PGCACHE** should return EJUSTRETURN, and VFS would handle the rest of the read operation using the [VOP\_READ(9)](/VOP_READ/9.md).

The VFS layer does the same deadlock avoidance for accessing userspace pages from **VOP\_READ\_PGCACHE** as for [VOP\_READ(9)](/VOP_READ/9.md).

Vnode is not locked on the call entry and should not be locked on return. For a filesystem that requires vnode lock to return any data, it does not make sense to implement **VOP\_READ\_PGCACHE** (and set VIRF\_PGREAD flag) since VFS arranges the call to [VOP\_READ(9)](/VOP_READ/9.md) as needed.

The arguments are:

- *vp*

  The vnode of the file.

- *uio*

  The location of the data to be read.

- *ioflag*

  Various flags, see [VOP\_READ(9)](/VOP_READ/9.md) for the list.

- *cred*

  The credentials of the caller.

**VOP\_READ\_PGCACHE** does not handle non-zero *ioflag* argument.

## LOCKS

The file should be referenced on entry on entry and will still be referenced on exit. Rangelock covering the whole read range should be owned around the call.

## RETURN VALUES

Zero is returned on success, when the whole request is satisfied, and no more data cannot be provided for it by any means. If more data can be returned, but **VOP\_READ\_PGCACHE** was unable to provide it, EJUSTRETURN must be returned. The uio records should be updated according to the partial operation done.

Otherwise an error code is returned, same as from [VOP\_READ(9)](/VOP_READ/9.md)

## SEE ALSO

[uiomove(9)](/uiomove/9.md), [vnode(9)](/vnode/9.md), [VOP\_READ(9)](/VOP_READ/9.md)
