1997-03-03 18:01:01 +00:00
|
|
|
.\" -*- nroff -*-
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1996 Doug Rabson
|
2003-09-28 03:15:21 +00:00
|
|
|
.\" Copyright 2003, Garrett A. Wollman
|
1997-03-03 18:01:01 +00:00
|
|
|
.\"
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This program is free software.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1997-03-03 18:01:01 +00:00
|
|
|
.\"
|
2017-05-07 19:01:08 +00:00
|
|
|
.Dd May 7, 2017
|
1997-03-03 18:01:01 +00:00
|
|
|
.Dt VOP_GETPAGES 9
|
2010-04-14 19:08:06 +00:00
|
|
|
.Os
|
1997-03-03 18:01:01 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm VOP_GETPAGES ,
|
|
|
|
.Nm VOP_PUTPAGES
|
|
|
|
.Nd read or write VM pages from a file
|
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/param.h
|
|
|
|
.In sys/vnode.h
|
|
|
|
.In vm/vm.h
|
1997-03-03 18:01:01 +00:00
|
|
|
.Ft int
|
2017-05-07 19:01:08 +00:00
|
|
|
.Fo VOP_GETPAGES
|
|
|
|
.Fa "struct vnode *vp"
|
|
|
|
.Fa "vm_page_t *ma"
|
|
|
|
.Fa "int count"
|
|
|
|
.Fa "int *rbehind"
|
|
|
|
.Fa "int *rahead"
|
|
|
|
.Fc
|
1997-03-03 18:01:01 +00:00
|
|
|
.Ft int
|
2017-05-07 19:01:08 +00:00
|
|
|
.Fo VOP_PUTPAGES
|
|
|
|
.Fa "struct vnode *vp"
|
|
|
|
.Fa "vm_page_t *ma"
|
|
|
|
.Fa "int bytecount"
|
|
|
|
.Fa "int flags"
|
|
|
|
.Fa "int *rtvals"
|
|
|
|
.Fc
|
1997-03-03 18:01:01 +00:00
|
|
|
.Sh DESCRIPTION
|
2003-09-28 03:15:21 +00:00
|
|
|
The
|
|
|
|
.Fn 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,
|
|
|
|
.Fn VOP_GETPAGES
|
|
|
|
is requested to read those pages as well, although it is not required to
|
|
|
|
do so.
|
|
|
|
The
|
|
|
|
.Fn VOP_PUTPAGES
|
|
|
|
method does the converse; that is to say, it writes out adjacent dirty
|
|
|
|
pages of virtual memory.
|
|
|
|
.Pp
|
|
|
|
On entry, the vnode lock is held but neither the page queue nor VM object
|
2003-10-23 02:11:14 +00:00
|
|
|
locks are held.
|
|
|
|
Both methods return in the same state on both success and error returns.
|
2003-09-28 03:15:21 +00:00
|
|
|
.Pp
|
1997-03-03 18:01:01 +00:00
|
|
|
The arguments are:
|
A change to KPI of vm_pager_get_pages() and underlying VOP_GETPAGES().
o With new KPI consumers can request contiguous ranges of pages, and
unlike before, all pages will be kept busied on return, like it was
done before with the 'reqpage' only. Now the reqpage goes away. With
new interface it is easier to implement code protected from race
conditions.
Such arrayed requests for now should be preceeded by a call to
vm_pager_haspage() to make sure that request is possible. This
could be improved later, making vm_pager_haspage() obsolete.
Strenghtening the promises on the business of the array of pages
allows us to remove such hacks as swp_pager_free_nrpage() and
vm_pager_free_nonreq().
o New KPI accepts two integer pointers that may optionally point at
values for read ahead and read behind, that a pager may do, if it
can. These pages are completely owned by pager, and not controlled
by the caller.
This shifts the UFS-specific readahead logic from vm_fault.c, which
should be file system agnostic, into vnode_pager.c. It also removes
one VOP_BMAP() request per hard fault.
Discussed with: kib, alc, jeff, scottl
Sponsored by: Nginx, Inc.
Sponsored by: Netflix
2015-12-16 21:30:45 +00:00
|
|
|
.Bl -tag -width rbehind
|
2003-05-31 14:07:25 +00:00
|
|
|
.It Fa vp
|
1997-03-03 18:01:01 +00:00
|
|
|
The file to access.
|
2010-10-20 05:57:54 +00:00
|
|
|
.It Fa ma
|
|
|
|
Pointer to the first element of an array of pages representing a
|
2003-09-28 03:15:21 +00:00
|
|
|
contiguous region of the file to be read or written.
|
2003-05-31 14:07:25 +00:00
|
|
|
.It Fa count
|
2017-05-07 19:01:08 +00:00
|
|
|
The length of the
|
|
|
|
.Fa ma
|
|
|
|
array.
|
|
|
|
.It Fa bytecount
|
|
|
|
The number of bytes that should be written from the pages of the array.
|
|
|
|
.It Fa flags
|
|
|
|
A bitfield of flags affecting the function operation.
|
|
|
|
If
|
2003-09-28 03:15:21 +00:00
|
|
|
.Dv VM_PAGER_PUT_SYNC
|
2017-05-07 19:01:08 +00:00
|
|
|
is set, the write should be synchronous; control must not be returned
|
|
|
|
to the caller until after the write is finished.
|
|
|
|
If
|
|
|
|
.Dv VM_PAGER_PUT_INVAL
|
|
|
|
is set, the pages are to be invalidated after being written.
|
|
|
|
If
|
|
|
|
.Dv 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
|
|
|
|
.Xr vm_page_deactivate_noreuse 9 ,
|
|
|
|
which puts such pages onto the head of the inactive queue.
|
|
|
|
If
|
|
|
|
.Dv VM_PAGER_CLUSTER_OK
|
|
|
|
is set, writes may be performed asynchronously, so that related writes
|
|
|
|
can be coalesced for efficiency, e.g.,
|
|
|
|
using the clustering mechanism of the buffer cache.
|
2003-05-31 14:07:25 +00:00
|
|
|
.It Fa rtvals
|
2003-09-28 03:15:21 +00:00
|
|
|
An array of VM system result codes indicating the status of each
|
|
|
|
page written by
|
|
|
|
.Fn VOP_PUTPAGES .
|
A change to KPI of vm_pager_get_pages() and underlying VOP_GETPAGES().
o With new KPI consumers can request contiguous ranges of pages, and
unlike before, all pages will be kept busied on return, like it was
done before with the 'reqpage' only. Now the reqpage goes away. With
new interface it is easier to implement code protected from race
conditions.
Such arrayed requests for now should be preceeded by a call to
vm_pager_haspage() to make sure that request is possible. This
could be improved later, making vm_pager_haspage() obsolete.
Strenghtening the promises on the business of the array of pages
allows us to remove such hacks as swp_pager_free_nrpage() and
vm_pager_free_nonreq().
o New KPI accepts two integer pointers that may optionally point at
values for read ahead and read behind, that a pager may do, if it
can. These pages are completely owned by pager, and not controlled
by the caller.
This shifts the UFS-specific readahead logic from vm_fault.c, which
should be file system agnostic, into vnode_pager.c. It also removes
one VOP_BMAP() request per hard fault.
Discussed with: kib, alc, jeff, scottl
Sponsored by: Nginx, Inc.
Sponsored by: Netflix
2015-12-16 21:30:45 +00:00
|
|
|
.It Fa 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.
|
|
|
|
.It Fa 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.
|
2003-09-28 03:15:21 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The status of the
|
|
|
|
.Fn VOP_PUTPAGES
|
2004-06-16 08:33:57 +00:00
|
|
|
method is returned on a page-by-page basis in the array
|
2003-09-28 03:15:21 +00:00
|
|
|
.Fa rtvals[] .
|
|
|
|
The possible status values are as follows:
|
|
|
|
.Bl -tag -width VM_PAGER_ERROR
|
|
|
|
.It Dv VM_PAGER_OK
|
|
|
|
The page was successfully written.
|
|
|
|
The implementation must call
|
2005-01-21 10:17:17 +00:00
|
|
|
.Xr vm_page_undirty 9
|
2003-09-28 03:15:21 +00:00
|
|
|
to mark the page as clean.
|
|
|
|
.It Dv VM_PAGER_PEND
|
|
|
|
The page was scheduled to be written asynchronously.
|
|
|
|
When the write completes, the completion callback should
|
|
|
|
call
|
|
|
|
.Xr vm_object_pip_wakeup 9
|
|
|
|
and
|
2013-08-09 11:11:11 +00:00
|
|
|
.Xr vm_page_sunbusy 9
|
2003-09-28 03:15:21 +00:00
|
|
|
to clear the busy flag and awaken any other threads waiting for this page,
|
|
|
|
in addition to calling
|
|
|
|
.Xr vm_page_undirty 9 .
|
|
|
|
.It Dv VM_PAGER_BAD
|
|
|
|
The page was entirely beyond the end of the backing file.
|
2005-06-15 13:31:23 +00:00
|
|
|
This condition should not be possible if the vnode's file system
|
2003-09-28 03:15:21 +00:00
|
|
|
is correctly implemented.
|
|
|
|
.It Dv VM_PAGER_ERROR
|
|
|
|
The page could not be written because of an error on the underlying storage
|
|
|
|
medium or protocol.
|
|
|
|
.It Dv VM_PAGER_FAIL
|
|
|
|
Treated identically to
|
2012-05-20 16:43:47 +00:00
|
|
|
.Dv VM_PAGER_ERROR .
|
2003-09-28 03:15:21 +00:00
|
|
|
.It Dv VM_PAGER_AGAIN
|
|
|
|
The page was not handled by this request.
|
1997-03-03 18:01:01 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2003-09-28 03:15:21 +00:00
|
|
|
The
|
|
|
|
.Fn VOP_GETPAGES
|
2017-05-07 19:01:08 +00:00
|
|
|
method must populate and validate all requested pages in order to
|
|
|
|
return success.
|
|
|
|
It is expected to release any pages in
|
2010-10-20 05:57:54 +00:00
|
|
|
.Fa ma
|
2003-09-28 03:15:21 +00:00
|
|
|
that it does not successfully handle, by calling
|
|
|
|
.Xr vm_page_free 9 .
|
|
|
|
When it succeeds,
|
|
|
|
.Fn VOP_GETPAGES
|
2010-10-20 05:57:54 +00:00
|
|
|
must set the valid bits appropriately.
|
2017-05-07 19:01:08 +00:00
|
|
|
Upon entry to
|
|
|
|
.Fn VOP_GETPAGES ,
|
|
|
|
all pages in
|
|
|
|
.Fa 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
|
2010-10-20 05:57:54 +00:00
|
|
|
.Fn VOP_GETPAGES
|
2017-05-07 19:01:08 +00:00
|
|
|
depending on the architecture of the particular filesystem.
|
1997-03-03 18:01:01 +00:00
|
|
|
.Sh RETURN VALUES
|
2017-05-07 19:01:08 +00:00
|
|
|
If it successfully reads all pages in
|
|
|
|
.Fa ma ,
|
2003-09-28 03:15:21 +00:00
|
|
|
.Fn VOP_GETPAGES
|
|
|
|
returns
|
|
|
|
.Dv VM_PAGER_OK ;
|
2017-05-07 19:01:08 +00:00
|
|
|
otherwise, it returns
|
2003-09-28 03:15:21 +00:00
|
|
|
.Dv VM_PAGER_ERROR .
|
|
|
|
By convention, the return value of
|
|
|
|
.Fn VOP_PUTPAGES
|
|
|
|
is
|
|
|
|
.Fa rtvals[0] .
|
1997-03-03 18:01:01 +00:00
|
|
|
.Sh SEE ALSO
|
2003-09-28 03:15:21 +00:00
|
|
|
.Xr vm_object_pip_wakeup 9 ,
|
|
|
|
.Xr vm_page_free 9 ,
|
2014-09-12 08:33:53 +00:00
|
|
|
.Xr vm_page_sunbusy 9 ,
|
2003-09-28 03:15:21 +00:00
|
|
|
.Xr vm_page_undirty 9 ,
|
2013-08-09 11:11:11 +00:00
|
|
|
.Xr vm_page_xunbusy 9 ,
|
1997-03-03 18:01:01 +00:00
|
|
|
.Xr vnode 9
|
|
|
|
.Sh AUTHORS
|
2003-09-28 03:15:21 +00:00
|
|
|
This manual page was written by
|
|
|
|
.An Doug Rabson
|
|
|
|
and then substantially rewritten by
|
|
|
|
.An Garrett Wollman .
|