xref: /freebsd/share/man/man9/VOP_FSYNC.9 (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
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.\" $FreeBSD$
35.\"
36.Dd March 22, 2019
37.Dt VOP_FSYNC 9
38.Os
39.Sh NAME
40.Nm VOP_FDATASYNC ,
41.Nm VOP_FSYNC
42.Nd flush file system buffers for a file
43.Sh SYNOPSIS
44.In sys/param.h
45.In sys/vnode.h
46.Ft int
47.Fn VOP_FDATASYNC "struct vnode *vp" "struct thread *td"
48.Ft int
49.Fn VOP_FSYNC "struct vnode *vp" "int waitfor" "struct thread *td"
50.Sh DESCRIPTION
51.Fn VOP_FSYNC
52ensures that a file can be recovered to its current state following a crash.
53That typically requires flushing the file's dirty buffers, its inode, and
54possibly other filesystem metadata to persistent media.
55.Fn VOP_FSYNC
56is used to implement the
57.Xr sync 2
58and
59.Xr fsync 2
60system calls.
61.Pp
62Its arguments are:
63.Bl -tag -width waitfor
64.It Fa vp
65The vnode of the file.
66.It Fa waitfor
67Whether the function should wait for I/O to complete.
68Possible values are:
69.Bl -tag -width MNT_NOWAIT
70.It Dv MNT_WAIT
71Synchronously wait for I/O to complete.
72.It Dv MNT_NOWAIT
73Start all I/O, but do not wait for it.
74.It Dv MNT_LAZY
75Push data not written by file system syncer.
76.El
77.It Fa td
78The calling thread.
79.El
80.Pp
81.Fn VOP_FDATASYNC
82is similar, but it does not require that all of the file's metadata be flushed.
83It only requires that the file's data be recoverable after a crash.
84That implies that the data itself must be flushed to disk, as well as some
85metadata such as the file's size but not necessarily its attributes.
86.Fn VOP_FDATASYNC
87should always wait for I/O to complete, as if called with
88.Dv MNT_WAIT .
89.Fn VOP_FDATASYNC
90is used to implement
91.Xr fdatasync 2 .
92.Sh LOCKS
93The vnode should be exclusively locked on entry, and stays locked on return.
94.Sh RETURN VALUES
95Zero is returned if the call is successful, otherwise an appropriate
96error code is returned.
97.Sh ERRORS
98.Bl -tag -width Er
99.It Bq Er ENOSPC
100The file system is full.
101.It Bq Er EDQUOT
102Quota exceeded.
103.El
104.Sh SEE ALSO
105.Xr vnode 9
106.Sh AUTHORS
107This manual page was written by
108.An Doug Rabson .
109