xref: /freebsd/share/man/man9/vnode_pager_setsize.9 (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1.\"
2.\" SPDX-License-Identifier: BSD-2-Clause
3.\"
4.\" Copyright (c) 2021 The FreeBSD Foundation
5.\"
6.\" Portions of this software were developed by Ka Ho Ng
7.\" under sponsorship from the FreeBSD Foundation.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd April 8, 2021
31.Dt VNODE_PAGER_SETSIZE 9
32.Os
33.Sh NAME
34.Nm vnode_pager_setsize
35.Nd "notify the VM system about updates in the file size"
36.Sh SYNOPSIS
37.In sys/param.h
38.In vm/vm.h
39.In vm/vm_extern.h
40.Ft void
41.Fn vnode_pager_setsize "struct vnode *vp" "vm_ooffset_t nsize"
42.Sh DESCRIPTION
43.Nm
44lets the VM system know about a change in size for a file,
45and updates the object size and vnode pager size of the vm object in
46.Fa vp
47with
48.Fa nsize .
49Page faults on the object mapping with offset beyond the new object
50size results in
51.Va SIGBUS .
52.Pp
53Pages between the old EOF and the new EOF are removed from the object queue
54if the file size shrinks.
55In case the new EOF specified by the
56.Fa nsize
57argument is not aligned to page boundary,
58partial-page area starting beyond the EOF is zeroed and marked invalid.
59if the page exists resident.
60.Pp
61In case the vnode
62.Fa vp
63does not have a VM object allocated, the effect of calling this function is no-op.
64.Pp
65This function must be used within file system code to implement truncation
66if the file system allocates vm objects for vnodes.
67.Sh LOCKS
68The vnode should be exclusively locked on entry and will still be locked on exit.
69.Sh SEE ALSO
70.Xr vnode 9
71.Sh HISTORY
72The
73.Nm
74manual page first appeared in
75.Fx 14 .
76.Sh AUTHORS
77This
78manual page was written by
79.An Ka Ho Ng Aq Mt khng@FreeBSD.org .
80