1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
<table class="head">
<tr>
<td class="head-ltitle">VOP_READ_PGCACHE(9)</td>
<td class="head-vol">Kernel Developer's Manual</td>
<td class="head-rtitle">VOP_READ_PGCACHE(9)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">VOP_READ_PGCACHE</code> —
<span class="Nd">read a file, fast</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
<<a class="In">sys/param.h</a>></code>
<br/>
<code class="In">#include <<a class="In">sys/vnode.h</a>></code>
<br/>
<code class="In">#include <<a class="In">sys/uio.h</a>></code></p>
<p class="Pp"><var class="Ft">int</var>
<br/>
<code class="Fn">VOP_READ_PGCACHE</code>(<var class="Fa">struct vnode
*vp</var>, <var class="Fa">struct uio *uio</var>, <var class="Fa">int
ioflag</var>, <var class="Fa">struct ucred *cred</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">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 <code class="Dv">v_object</code> lifetime, it can use
<a class="Xr">vn_read_from_obj(9)</a> helper to return data from the
resident <code class="Dv">vp->v_object</code> pages.</p>
<p class="Pp">The filesystem indicates support for the
<code class="Nm">VOP_READ_PGCACHE</code> on specific vnode by setting the
<code class="Dv">VIRF_PGREAD</code> flag in
<code class="Dv">vp->v_irflag</code>.</p>
<p class="Pp">The function does not need to satisfy the whole request; it also
might choose to not provide any data. In these cases, the
<var class="Fa">uio</var> must be advanced by the amount of read data,
<code class="Nm">VOP_READ_PGCACHE</code> should return
<code class="Er">EJUSTRETURN</code>, and VFS would handle the rest of the
read operation using the <a class="Xr">VOP_READ(9)</a>.</p>
<p class="Pp">The VFS layer does the same deadlock avoidance for accessing
userspace pages from <code class="Nm">VOP_READ_PGCACHE</code> as for
<a class="Xr">VOP_READ(9)</a>.</p>
<p class="Pp">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 <code class="Nm">VOP_READ_PGCACHE</code>
(and set <code class="Dv">VIRF_PGREAD</code> flag) since VFS arranges the
call to <a class="Xr">VOP_READ(9)</a> as needed.</p>
<p class="Pp">The arguments are:</p>
<dl class="Bl-tag">
<dt><var class="Fa">vp</var></dt>
<dd>The vnode of the file.</dd>
<dt><var class="Fa">uio</var></dt>
<dd>The location of the data to be read.</dd>
<dt><var class="Fa">ioflag</var></dt>
<dd>Various flags, see <a class="Xr">VOP_READ(9)</a> for the list.</dd>
<dt><var class="Fa">cred</var></dt>
<dd>The credentials of the caller.</dd>
</dl>
<p class="Pp"><code class="Nm">VOP_READ_PGCACHE</code> does not handle non-zero
<var class="Fa">ioflag</var> argument.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="LOCKS"><a class="permalink" href="#LOCKS">LOCKS</a></h1>
<p class="Pp">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.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
VALUES</a></h1>
<p class="Pp">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 <code class="Nm">VOP_READ_PGCACHE</code> was unable to provide
it, <code class="Er">EJUSTRETURN</code> must be returned. The
<code class="Dv">uio</code> records should be updated according to the
partial operation done.</p>
<p class="Pp">Otherwise an error code is returned, same as from
<a class="Xr">VOP_READ(9)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><a class="Xr">uiomove(9)</a>, <a class="Xr">vnode(9)</a>,
<a class="Xr">VOP_READ(9)</a></p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">February 28, 2021</td>
<td class="foot-os">FreeBSD 15.0</td>
</tr>
</table>
|