xref: /freebsd/lib/libsys/aio_fsync.2 (revision e24279e0f9e28ba0c1920cb539fc357568790c0a)
1*8269e767SBrooks Davis.\" Copyright (c) 2013 Sergey Kandaurov
2*8269e767SBrooks Davis.\" All rights reserved.
3*8269e767SBrooks Davis.\"
4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
6*8269e767SBrooks Davis.\" are met:
7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
8*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
10*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
11*8269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
12*8269e767SBrooks Davis.\"
13*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*8269e767SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*8269e767SBrooks Davis.\" SUCH DAMAGE.
24*8269e767SBrooks Davis.\"
25*8269e767SBrooks Davis.Dd November 15, 2023
26*8269e767SBrooks Davis.Dt AIO_FSYNC 2
27*8269e767SBrooks Davis.Os
28*8269e767SBrooks Davis.Sh NAME
29*8269e767SBrooks Davis.Nm aio_fsync
30*8269e767SBrooks Davis.Nd asynchronous file synchronization (REALTIME)
31*8269e767SBrooks Davis.Sh LIBRARY
32*8269e767SBrooks Davis.Lb libc
33*8269e767SBrooks Davis.Sh SYNOPSIS
34*8269e767SBrooks Davis.In aio.h
35*8269e767SBrooks Davis.Ft int
36*8269e767SBrooks Davis.Fn aio_fsync "int op" "struct aiocb *iocb"
37*8269e767SBrooks Davis.Sh DESCRIPTION
38*8269e767SBrooks DavisThe
39*8269e767SBrooks Davis.Fn aio_fsync
40*8269e767SBrooks Davissystem call allows the calling process to move all modified data
41*8269e767SBrooks Davisassociated with the descriptor
42*8269e767SBrooks Davis.Fa iocb->aio_fildes
43*8269e767SBrooks Davisto a permanent storage device.
44*8269e767SBrooks DavisThe call returns immediately after the synchronization request has been
45*8269e767SBrooks Davisenqueued to the descriptor; the synchronization may or may not have
46*8269e767SBrooks Daviscompleted at the time the call returns.
47*8269e767SBrooks Davis.Pp
48*8269e767SBrooks DavisThe
49*8269e767SBrooks Davis.Fa op
50*8269e767SBrooks Davisargument can be set to
51*8269e767SBrooks Davis.Dv O_SYNC
52*8269e767SBrooks Davisto cause all currently queued I/O operations to be completed
53*8269e767SBrooks Davisas if by a call to
54*8269e767SBrooks Davis.Xr fsync 2 ,
55*8269e767SBrooks Davisor
56*8269e767SBrooks Davis.Dv O_DSYNC
57*8269e767SBrooks Davisfor the behavior of
58*8269e767SBrooks Davis.Xr fdatasync 2 .
59*8269e767SBrooks Davis.Pp
60*8269e767SBrooks DavisThe
61*8269e767SBrooks Davis.Fa iocb
62*8269e767SBrooks Davispointer may be subsequently used as an argument to
63*8269e767SBrooks Davis.Fn aio_return
64*8269e767SBrooks Davisand
65*8269e767SBrooks Davis.Fn aio_error
66*8269e767SBrooks Davisin order to determine return or error status for the enqueued operation
67*8269e767SBrooks Daviswhile it is in progress.
68*8269e767SBrooks Davis.Pp
69*8269e767SBrooks DavisIf the request could not be enqueued (generally due to invalid arguments),
70*8269e767SBrooks Davisthe call returns without having enqueued the request.
71*8269e767SBrooks Davis.Pp
72*8269e767SBrooks DavisThe
73*8269e767SBrooks Davis.Fa iocb->aio_sigevent
74*8269e767SBrooks Davisstructure can be used to request notification of the operation's
75*8269e767SBrooks Daviscompletion as described in
76*8269e767SBrooks Davis.Xr aio 4 .
77*8269e767SBrooks Davis.Sh RESTRICTIONS
78*8269e767SBrooks DavisThe Asynchronous I/O Control Block structure pointed to by
79*8269e767SBrooks Davis.Fa iocb
80*8269e767SBrooks Davismust remain valid until the
81*8269e767SBrooks Davisoperation has completed.
82*8269e767SBrooks Davis.Pp
83*8269e767SBrooks DavisThe asynchronous I/O control buffer
84*8269e767SBrooks Davis.Fa iocb
85*8269e767SBrooks Davisshould be zeroed before the
86*8269e767SBrooks Davis.Fn aio_fsync
87*8269e767SBrooks Daviscall to avoid passing bogus context information to the kernel.
88*8269e767SBrooks Davis.Pp
89*8269e767SBrooks DavisModification of the Asynchronous I/O Control Block structure is not allowed
90*8269e767SBrooks Daviswhile the request is queued.
91*8269e767SBrooks Davis.Sh RETURN VALUES
92*8269e767SBrooks Davis.Rv -std aio_fsync
93*8269e767SBrooks Davis.Sh ERRORS
94*8269e767SBrooks DavisThe
95*8269e767SBrooks Davis.Fn aio_fsync
96*8269e767SBrooks Davissystem call will fail if:
97*8269e767SBrooks Davis.Bl -tag -width Er
98*8269e767SBrooks Davis.It Bq Er EAGAIN
99*8269e767SBrooks DavisThe request was not queued because of system resource limitations.
100*8269e767SBrooks Davis.It Bq Er EINVAL
101*8269e767SBrooks DavisThe asynchronous notification method in
102*8269e767SBrooks Davis.Fa iocb->aio_sigevent.sigev_notify
103*8269e767SBrooks Davisis invalid or not supported.
104*8269e767SBrooks Davis.It Bq Er EOPNOTSUPP
105*8269e767SBrooks DavisAsynchronous file synchronization operations on the file descriptor
106*8269e767SBrooks Davis.Fa iocb->aio_fildes
107*8269e767SBrooks Davisare unsafe and unsafe asynchronous I/O operations are disabled.
108*8269e767SBrooks Davis.It Bq Er EINVAL
109*8269e767SBrooks DavisA value of the
110*8269e767SBrooks Davis.Fa op
111*8269e767SBrooks Davisargument is not set to
112*8269e767SBrooks Davis.Dv O_SYNC
113*8269e767SBrooks Davisor
114*8269e767SBrooks Davis.Dv O_DSYNC .
115*8269e767SBrooks Davis.El
116*8269e767SBrooks Davis.Pp
117*8269e767SBrooks DavisThe following conditions may be synchronously detected when the
118*8269e767SBrooks Davis.Fn aio_fsync
119*8269e767SBrooks Davissystem call is made, or asynchronously, at any time thereafter.
120*8269e767SBrooks DavisIf they are detected at call time,
121*8269e767SBrooks Davis.Fn aio_fsync
122*8269e767SBrooks Davisreturns -1 and sets
123*8269e767SBrooks Davis.Va errno
124*8269e767SBrooks Davisappropriately; otherwise the
125*8269e767SBrooks Davis.Fn aio_return
126*8269e767SBrooks Davissystem call must be called, and will return -1, and
127*8269e767SBrooks Davis.Fn aio_error
128*8269e767SBrooks Davismust be called to determine the actual value that would have been
129*8269e767SBrooks Davisreturned in
130*8269e767SBrooks Davis.Va errno .
131*8269e767SBrooks Davis.Bl -tag -width Er
132*8269e767SBrooks Davis.It Bq Er EBADF
133*8269e767SBrooks DavisThe
134*8269e767SBrooks Davis.Fa iocb->aio_fildes
135*8269e767SBrooks Davisargument
136*8269e767SBrooks Davisis not a valid descriptor.
137*8269e767SBrooks Davis.It Bq Er EINVAL
138*8269e767SBrooks DavisThis implementation does not support synchronized I/O for this file.
139*8269e767SBrooks Davis.El
140*8269e767SBrooks Davis.Pp
141*8269e767SBrooks DavisIf the request is successfully enqueued, but subsequently cancelled
142*8269e767SBrooks Davisor an error occurs, the value returned by the
143*8269e767SBrooks Davis.Fn aio_return
144*8269e767SBrooks Davissystem call is per the
145*8269e767SBrooks Davis.Xr read 2
146*8269e767SBrooks Davisand
147*8269e767SBrooks Davis.Xr write 2
148*8269e767SBrooks Davissystem calls, and the value returned by the
149*8269e767SBrooks Davis.Fn aio_error
150*8269e767SBrooks Davissystem call is one of the error returns from the
151*8269e767SBrooks Davis.Xr read 2
152*8269e767SBrooks Davisor
153*8269e767SBrooks Davis.Xr write 2
154*8269e767SBrooks Davissystem calls.
155*8269e767SBrooks Davis.Sh SEE ALSO
156*8269e767SBrooks Davis.Xr aio_cancel 2 ,
157*8269e767SBrooks Davis.Xr aio_error 2 ,
158*8269e767SBrooks Davis.Xr aio_read 2 ,
159*8269e767SBrooks Davis.Xr aio_return 2 ,
160*8269e767SBrooks Davis.Xr aio_suspend 2 ,
161*8269e767SBrooks Davis.Xr aio_waitcomplete 2 ,
162*8269e767SBrooks Davis.Xr aio_write 2 ,
163*8269e767SBrooks Davis.Xr fsync 2 ,
164*8269e767SBrooks Davis.Xr sigevent 3 ,
165*8269e767SBrooks Davis.Xr siginfo 3 ,
166*8269e767SBrooks Davis.Xr aio 4
167*8269e767SBrooks Davis.Sh STANDARDS
168*8269e767SBrooks DavisThe
169*8269e767SBrooks Davis.Fn aio_fsync
170*8269e767SBrooks Davissystem call is expected to conform to the
171*8269e767SBrooks Davis.St -p1003.1
172*8269e767SBrooks Davisstandard.
173*8269e767SBrooks Davis.Sh HISTORY
174*8269e767SBrooks DavisThe
175*8269e767SBrooks Davis.Fn aio_fsync
176*8269e767SBrooks Davissystem call first appeared in
177*8269e767SBrooks Davis.Fx 7.0 .
178*8269e767SBrooks DavisThe
179*8269e767SBrooks Davis.Dv O_DSYNC
180*8269e767SBrooks Davisoption appeared in
181*8269e767SBrooks Davis.Fx 13.0 .
182