186a52e26SKa Ho Ng.\" 2*4d846d26SWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause 386a52e26SKa Ho Ng.\" 486a52e26SKa Ho Ng.\" Copyright (c) 2021 The FreeBSD Foundation 586a52e26SKa Ho Ng.\" 686a52e26SKa Ho Ng.\" Portions of this software were developed by Ka Ho Ng 786a52e26SKa Ho Ng.\" under sponsorship from the FreeBSD Foundation. 886a52e26SKa Ho Ng.\" 986a52e26SKa Ho Ng.\" Redistribution and use in source and binary forms, with or without 1086a52e26SKa Ho Ng.\" modification, are permitted provided that the following conditions 1186a52e26SKa Ho Ng.\" are met: 1286a52e26SKa Ho Ng.\" 1. Redistributions of source code must retain the above copyright 1386a52e26SKa Ho Ng.\" notice, this list of conditions and the following disclaimer. 1486a52e26SKa Ho Ng.\" 2. Redistributions in binary form must reproduce the above copyright 1586a52e26SKa Ho Ng.\" notice, this list of conditions and the following disclaimer in the 1686a52e26SKa Ho Ng.\" documentation and/or other materials provided with the distribution. 1786a52e26SKa Ho Ng.\" 1886a52e26SKa Ho Ng.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1986a52e26SKa Ho Ng.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2086a52e26SKa Ho Ng.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2186a52e26SKa Ho Ng.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2286a52e26SKa Ho Ng.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2386a52e26SKa Ho Ng.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2486a52e26SKa Ho Ng.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2586a52e26SKa Ho Ng.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2686a52e26SKa Ho Ng.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2786a52e26SKa Ho Ng.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2886a52e26SKa Ho Ng.\" SUCH DAMAGE. 2986a52e26SKa Ho Ng.\" 30b77f5f55SKa Ho Ng.Dd April 8, 2021 3186a52e26SKa Ho Ng.Dt VNODE_PAGER_SETSIZE 9 3286a52e26SKa Ho Ng.Os 3386a52e26SKa Ho Ng.Sh NAME 3486a52e26SKa Ho Ng.Nm vnode_pager_setsize 3586a52e26SKa Ho Ng.Nd "notify the VM system about updates in the file size" 3686a52e26SKa Ho Ng.Sh SYNOPSIS 3786a52e26SKa Ho Ng.In sys/param.h 3886a52e26SKa Ho Ng.In vm/vm.h 3986a52e26SKa Ho Ng.In vm/vm_extern.h 4086a52e26SKa Ho Ng.Ft void 4186a52e26SKa Ho Ng.Fn vnode_pager_setsize "struct vnode *vp" "vm_ooffset_t nsize" 4286a52e26SKa Ho Ng.Sh DESCRIPTION 4386a52e26SKa Ho Ng.Nm 44b77f5f55SKa Ho Nglets the VM system know about a change in size for a file, 45b77f5f55SKa Ho Ngand updates the object size and vnode pager size of the vm object in 46b77f5f55SKa Ho Ng.Fa vp 47b77f5f55SKa Ho Ngwith 48b77f5f55SKa Ho Ng.Fa nsize . 49b77f5f55SKa Ho NgPage faults on the object mapping with offset beyond the new object 50b77f5f55SKa Ho Ngsize results in 51b77f5f55SKa Ho Ng.Va SIGBUS . 52b77f5f55SKa Ho Ng.Pp 53b77f5f55SKa Ho NgPages between the old EOF and the new EOF are removed from the object queue 54b77f5f55SKa Ho Ngif the file size shrinks. 5586a52e26SKa Ho NgIn case the new EOF specified by the 5686a52e26SKa Ho Ng.Fa nsize 57b77f5f55SKa Ho Ngargument is not aligned to page boundary, 58b77f5f55SKa Ho Ngpartial-page area starting beyond the EOF is zeroed and marked invalid. 59b77f5f55SKa Ho Ngif the page exists resident. 60b77f5f55SKa Ho Ng.Pp 61b77f5f55SKa Ho NgIn case the vnode 6286a52e26SKa Ho Ng.Fa vp 63b77f5f55SKa Ho Ngdoes not have a VM object allocated, the effect of calling this function is no-op. 64b77f5f55SKa Ho Ng.Pp 65b77f5f55SKa Ho NgThis function must be used within file system code to implement truncation 66b77f5f55SKa Ho Ngif the file system allocates vm objects for vnodes. 67b77f5f55SKa Ho Ng.Sh LOCKS 68b77f5f55SKa Ho NgThe vnode should be exclusively locked on entry and will still be locked on exit. 6986a52e26SKa Ho Ng.Sh SEE ALSO 7086a52e26SKa Ho Ng.Xr vnode 9 7186a52e26SKa Ho Ng.Sh HISTORY 7286a52e26SKa Ho NgThe 7386a52e26SKa Ho Ng.Nm 7486a52e26SKa Ho Ngmanual page first appeared in 7586a52e26SKa Ho Ng.Fx 14 . 7686a52e26SKa Ho Ng.Sh AUTHORS 7786a52e26SKa Ho NgThis 7886a52e26SKa Ho Ngmanual page was written by 7986a52e26SKa Ho Ng.An Ka Ho Ng Aq Mt khng@FreeBSD.org . 80