xref: /netbsd-src/lib/librt/aio_fsync.3 (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1.\" $NetBSD: aio_fsync.3,v 1.2 2007/08/07 20:45:03 wiz Exp $
2.\"
3.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"        This product includes software developed by the NetBSD
17.\"        Foundation, Inc. and its contributors.
18.\" 4. Neither the name of The NetBSD Foundation nor the names of its
19.\"    contributors may be used to endorse or promote products derived
20.\"    from this software without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32.\" POSSIBILITY OF SUCH DAMAGE.
33.\"
34.Dd June 17, 2007
35.Dt AIO_FSYNC 3
36.Os
37.Sh NAME
38.Nm aio_fsync
39.Nd asynchronous data synchronization of file (REALTIME)
40.Sh LIBRARY
41.Lb librt
42.Sh SYNOPSIS
43.In aio.h
44.Ft int
45.Fn aio_fsync "int op" "struct aiocb *aiocbp"
46.Sh DESCRIPTION
47The
48.Fn aio_fsync
49system call allows the calling process to force all modified data
50associated with the file descriptor
51.Fa aiocbp-\*[Gt]aio_fildes
52to be flushed to the stable storage device.
53The call returns immediately after the synchronization request has been
54enqueued to the descriptor; the synchronization may or may not have
55completed at the time the call returns.
56If the request could not be enqueued, generally due to invalid arguments,
57the call returns without having enqueued the request.
58.Pp
59The
60.Fa op
61argument could be set only to
62.Dv O_DSYNC
63or
64.Dv O_SYNC .
65If
66.Fa op
67is
68.Dv O_DSYNC ,
69then
70.Fn aio_fsync
71does the same as a
72.Fn fdatasync
73call, if
74.Dv O_SYNC ,
75then the same as
76.Fn fsync .
77.Pp
78If
79.Dv _POSIX_PRIORITIZED_IO
80is defined, and the descriptor supports it, then the enqueued
81operation is submitted at a priority equal to that of the calling
82process minus
83.Fa aiocbp-\*[Gt]aio_reqprio .
84.Pp
85The
86.Fa aiocbp
87pointer may be subsequently used as an argument to
88.Fn aio_return
89and
90.Fn aio_error
91in order to determine return or error status for the enqueued operation
92while it is in progress.
93.Sh RESTRICTIONS
94The asynchronous I/O control buffer
95.Fa aiocbp
96should be zeroed before the
97.Fn aio_fsync
98system call to avoid passing bogus context information to the kernel.
99.Pp
100Modifications of the Asynchronous I/O Control Block structure after
101the request has been enqueued, but before the request has completed,
102are not allowed.
103.Sh RETURN VALUES
104.Rv -std aio_fsync
105.Sh ERRORS
106.Bl -tag -width Er
107The
108.Fn aio_fsync
109system call will fail if:
110.It Bq Er EAGAIN
111The request was not queued because of system resource limitations.
112.El
113.Pp
114The following conditions may be synchronously detected when the
115.Fn aio_fsync
116system call is made, or asynchronously, at any time thereafter.
117If they are detected at call time,
118.Fn aio_fsync
119returns \-1 and sets
120.Va errno
121appropriately; otherwise the
122.Fn aio_return
123system call must be called, and will return \-1, and
124.Fn aio_error
125must be called to determine the actual value that would have been
126returned in
127.Va errno .
128.Bl -tag -width Er
129.It Bq Er EBADF
130The
131.Fa aiocbp-\*[Gt]aio_fildes
132is invalid for writing.
133.It Bq Er EINVAL
134This implementation does not support synchronized I/O for this file.
135.It Bq Er EINVAL
136The
137.Fa op
138argument is neither set to
139.Dv O_DSYNC
140nor
141.Dv O_SYNC .
142.El
143.Sh SEE ALSO
144.Xr fcntl 2 ,
145.Xr fdatasync 2 ,
146.Xr fsync 2 ,
147.Xr aio_error 3 ,
148.Xr aio_read 3 ,
149.Xr aio_write 3
150.Sh STANDARDS
151The
152.Fn aio_fsync
153system call is expected to conform to the
154.St -p1003.1-2001
155standard.
156.Sh HISTORY
157The
158.Fn aio_fsync
159system call first appeared in
160.Nx 5.0 .
161