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