xref: /freebsd/share/man/man9/VOP_FSYNC.9 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1fab63cc4SDoug Rabson.\" -*- nroff -*-
2fab63cc4SDoug Rabson.\"
3fab63cc4SDoug Rabson.\" Copyright (c) 1996 Doug Rabson
4fab63cc4SDoug Rabson.\"
5fab63cc4SDoug Rabson.\" All rights reserved.
6fab63cc4SDoug Rabson.\"
7*147b8ba8SAlan Somers.\" Copyright (c) 2019 The FreeBSD Foundation
8*147b8ba8SAlan Somers.\"
9*147b8ba8SAlan Somers.\" Portions of this documentation were written by BFF Storage Systems under
10*147b8ba8SAlan Somers.\" sponsorship from the FreeBSD Foundation.
11*147b8ba8SAlan Somers.\"
12fab63cc4SDoug Rabson.\" This program is free software.
13fab63cc4SDoug Rabson.\"
14fab63cc4SDoug Rabson.\" Redistribution and use in source and binary forms, with or without
15fab63cc4SDoug Rabson.\" modification, are permitted provided that the following conditions
16fab63cc4SDoug Rabson.\" are met:
17fab63cc4SDoug Rabson.\" 1. Redistributions of source code must retain the above copyright
18fab63cc4SDoug Rabson.\"    notice, this list of conditions and the following disclaimer.
19fab63cc4SDoug Rabson.\" 2. Redistributions in binary form must reproduce the above copyright
20fab63cc4SDoug Rabson.\"    notice, this list of conditions and the following disclaimer in the
21fab63cc4SDoug Rabson.\"    documentation and/or other materials provided with the distribution.
22fab63cc4SDoug Rabson.\"
23fab63cc4SDoug Rabson.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
24fab63cc4SDoug Rabson.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25fab63cc4SDoug Rabson.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26fab63cc4SDoug Rabson.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
27fab63cc4SDoug Rabson.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28fab63cc4SDoug Rabson.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29fab63cc4SDoug Rabson.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30fab63cc4SDoug Rabson.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31fab63cc4SDoug Rabson.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32fab63cc4SDoug Rabson.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33fab63cc4SDoug Rabson.\"
34f6a363a5SAlan Somers.Dd March 22, 2019
35fab63cc4SDoug Rabson.Dt VOP_FSYNC 9
36aa12cea2SUlrich Spörlein.Os
37fab63cc4SDoug Rabson.Sh NAME
38f6a363a5SAlan Somers.Nm VOP_FDATASYNC ,
39fab63cc4SDoug Rabson.Nm VOP_FSYNC
40fab63cc4SDoug Rabson.Nd flush file system buffers for a file
41fab63cc4SDoug Rabson.Sh SYNOPSIS
4232eef9aeSRuslan Ermilov.In sys/param.h
4332eef9aeSRuslan Ermilov.In sys/vnode.h
44fab63cc4SDoug Rabson.Ft int
45f6a363a5SAlan Somers.Fn VOP_FDATASYNC "struct vnode *vp" "struct thread *td"
46f6a363a5SAlan Somers.Ft int
471cf95db6SPav Lucistnik.Fn VOP_FSYNC "struct vnode *vp" "int waitfor" "struct thread *td"
48fab63cc4SDoug Rabson.Sh DESCRIPTION
49f6a363a5SAlan Somers.Fn VOP_FSYNC
50f6a363a5SAlan Somersensures that a file can be recovered to its current state following a crash.
51f6a363a5SAlan SomersThat typically requires flushing the file's dirty buffers, its inode, and
52f6a363a5SAlan Somerspossibly other filesystem metadata to persistent media.
53f6a363a5SAlan Somers.Fn VOP_FSYNC
54f6a363a5SAlan Somersis used to implement the
55fab63cc4SDoug Rabson.Xr sync 2
56fab63cc4SDoug Rabsonand
57fab63cc4SDoug Rabson.Xr fsync 2
58fab63cc4SDoug Rabsonsystem calls.
59fab63cc4SDoug Rabson.Pp
60fab63cc4SDoug RabsonIts arguments are:
61fab63cc4SDoug Rabson.Bl -tag -width waitfor
620640e9e0SHiten Pandya.It Fa vp
630a57ea7dSRuslan ErmilovThe vnode of the file.
640640e9e0SHiten Pandya.It Fa waitfor
650a57ea7dSRuslan ErmilovWhether the function should wait for I/O to complete.
66505f2a7eSAlexander LangerPossible values are:
67505f2a7eSAlexander Langer.Bl -tag -width MNT_NOWAIT
68505f2a7eSAlexander Langer.It Dv MNT_WAIT
690a57ea7dSRuslan ErmilovSynchronously wait for I/O to complete.
70505f2a7eSAlexander Langer.It Dv MNT_NOWAIT
710a57ea7dSRuslan ErmilovStart all I/O, but do not wait for it.
72505f2a7eSAlexander Langer.It Dv MNT_LAZY
730a57ea7dSRuslan ErmilovPush data not written by file system syncer.
74505f2a7eSAlexander Langer.El
750640e9e0SHiten Pandya.It Fa td
760a57ea7dSRuslan ErmilovThe calling thread.
77fab63cc4SDoug Rabson.El
78f6a363a5SAlan Somers.Pp
79f6a363a5SAlan Somers.Fn VOP_FDATASYNC
80f6a363a5SAlan Somersis similar, but it does not require that all of the file's metadata be flushed.
81f6a363a5SAlan SomersIt only requires that the file's data be recoverable after a crash.
82f6a363a5SAlan SomersThat implies that the data itself must be flushed to disk, as well as some
83f6a363a5SAlan Somersmetadata such as the file's size but not necessarily its attributes.
84f6a363a5SAlan Somers.Fn VOP_FDATASYNC
85f6a363a5SAlan Somersshould always wait for I/O to complete, as if called with
86f6a363a5SAlan Somers.Dv MNT_WAIT .
87f6a363a5SAlan Somers.Fn VOP_FDATASYNC
88f6a363a5SAlan Somersis used to implement
89f6a363a5SAlan Somers.Xr fdatasync 2 .
90fab63cc4SDoug Rabson.Sh LOCKS
91f6a363a5SAlan SomersThe vnode should be exclusively locked on entry, and stays locked on return.
92fab63cc4SDoug Rabson.Sh RETURN VALUES
93fab63cc4SDoug RabsonZero is returned if the call is successful, otherwise an appropriate
94fab63cc4SDoug Rabsonerror code is returned.
95fab63cc4SDoug Rabson.Sh ERRORS
96eaa8b244SMike Pritchard.Bl -tag -width Er
97fab63cc4SDoug Rabson.It Bq Er ENOSPC
98fab63cc4SDoug RabsonThe file system is full.
99fab63cc4SDoug Rabson.It Bq Er EDQUOT
100fab63cc4SDoug RabsonQuota exceeded.
101fab63cc4SDoug Rabson.El
102fab63cc4SDoug Rabson.Sh SEE ALSO
103fab63cc4SDoug Rabson.Xr vnode 9
104fab63cc4SDoug Rabson.Sh AUTHORS
105571dba6eSHiten PandyaThis manual page was written by
106aaf1f16eSPhilippe Charnier.An Doug Rabson .
107