xref: /freebsd/share/man/man9/VOP_FSYNC.9 (revision abd872540f24cfc7dbd1ea29b6918c7082a22108)
1.\" -*- nroff -*-
2.\"
3.\" Copyright (c) 1996 Doug Rabson
4.\"
5.\" All rights reserved.
6.\"
7.\" Copyright (c) 2019 The FreeBSD Foundation
8.\"
9.\" Portions of this documentation were written by BFF Storage Systems under
10.\" sponsorship from the FreeBSD Foundation.
11.\"
12.\" This program is free software.
13.\"
14.\" Redistribution and use in source and binary forms, with or without
15.\" modification, are permitted provided that the following conditions
16.\" are met:
17.\" 1. Redistributions of source code must retain the above copyright
18.\"    notice, this list of conditions and the following disclaimer.
19.\" 2. Redistributions in binary form must reproduce the above copyright
20.\"    notice, this list of conditions and the following disclaimer in the
21.\"    documentation and/or other materials provided with the distribution.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
24.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
27.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33.\"
34.Dd March 22, 2019
35.Dt VOP_FSYNC 9
36.Os
37.Sh NAME
38.Nm VOP_FDATASYNC ,
39.Nm VOP_FSYNC
40.Nd flush file system buffers for a file
41.Sh SYNOPSIS
42.In sys/param.h
43.In sys/vnode.h
44.Ft int
45.Fn VOP_FDATASYNC "struct vnode *vp" "struct thread *td"
46.Ft int
47.Fn VOP_FSYNC "struct vnode *vp" "int waitfor" "struct thread *td"
48.Sh DESCRIPTION
49.Fn VOP_FSYNC
50ensures that a file can be recovered to its current state following a crash.
51That typically requires flushing the file's dirty buffers, its inode, and
52possibly other filesystem metadata to persistent media.
53.Fn VOP_FSYNC
54is used to implement the
55.Xr sync 2
56and
57.Xr fsync 2
58system calls.
59.Pp
60Its arguments are:
61.Bl -tag -width waitfor
62.It Fa vp
63The vnode of the file.
64.It Fa waitfor
65Whether the function should wait for I/O to complete.
66Possible values are:
67.Bl -tag -width MNT_NOWAIT
68.It Dv MNT_WAIT
69Synchronously wait for I/O to complete.
70.It Dv MNT_NOWAIT
71Start all I/O, but do not wait for it.
72.It Dv MNT_LAZY
73Push data not written by file system syncer.
74.El
75.It Fa td
76The calling thread.
77.El
78.Pp
79.Fn VOP_FDATASYNC
80is similar, but it does not require that all of the file's metadata be flushed.
81It only requires that the file's data be recoverable after a crash.
82That implies that the data itself must be flushed to disk, as well as some
83metadata such as the file's size but not necessarily its attributes.
84.Fn VOP_FDATASYNC
85should always wait for I/O to complete, as if called with
86.Dv MNT_WAIT .
87.Fn VOP_FDATASYNC
88is used to implement
89.Xr fdatasync 2 .
90.Sh LOCKS
91The vnode should be exclusively locked on entry, and stays locked on return.
92.Sh RETURN VALUES
93Zero is returned if the call is successful, otherwise an appropriate
94error code is returned.
95.Sh ERRORS
96.Bl -tag -width Er
97.It Bq Er ENOSPC
98The file system is full.
99.It Bq Er EDQUOT
100Quota exceeded.
101.El
102.Sh SEE ALSO
103.Xr vnode 9
104.Sh AUTHORS
105This manual page was written by
106.An Doug Rabson .
107