]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man2/io_submit.2
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man2 / io_submit.2
CommitLineData
fea681da 1.\" Copyright (C) 2003 Free Software Foundation, Inc.
2be12b9e 2.\" and Copyright (C) 2017 Goldwyn Rodrigues <rgoldwyn@suse.de>
2297bf0e 3.\"
95fb8859 4.\" SPDX-License-Identifier: GPL-1.0-or-later
fea681da 5.\"
4c1c5274 6.TH io_submit 2 (date) "Linux man-pages (unreleased)"
fea681da 7.SH NAME
d12c1424 8io_submit \- submit asynchronous I/O blocks for processing
6b68f13c
AC
9.SH LIBRARY
10Standard C library
8fc3b2cf 11.RI ( libc ", " \-lc )
c6d039a3 12.P
6b68f13c 13Alternatively, Asynchronous I/O library
8fc3b2cf 14.RI ( libaio ", " \-laio );
4131356c 15see VERSIONS.
47297adb 16.SH SYNOPSIS
d12c1424 17.nf
e1c5ebfa 18.BR "#include <linux/aio_abi.h>" " /* Defines needed types */"
c6d039a3 19.P
1d597481 20.BI "int io_submit(aio_context_t " ctx_id ", long " nr \
d12c1424 21", struct iocb **" iocbpp );
d12c1424 22.fi
c6d039a3 23.P
45c99e3e 24.IR Note :
4131356c 25There is no glibc wrapper for this system call; see VERSIONS.
47297adb 26.SH DESCRIPTION
1d597481
AC
27.IR Note :
28this page describes the raw Linux system call interface.
29The wrapper function provided by
30.I libaio
31uses a different type for the
32.I ctx_id
33argument.
4131356c 34See VERSIONS.
c6d039a3 35.P
e1c5ebfa 36The
60a90ecd 37.BR io_submit ()
e1c5ebfa 38system call
a8d55537
MK
39queues \fInr\fP I/O request blocks for processing in
40the AIO context \fIctx_id\fP.
e1c5ebfa
MK
41The
42.I iocbpp
43argument should be an array of \fInr\fP AIO control blocks,
a8d55537 44which will be submitted to context \fIctx_id\fP.
c6d039a3 45.P
7a62a055
GR
46The
47.I iocb
2be12b9e 48(I/O control block) structure defined in
1ae6b2c7 49.I linux/aio_abi.h
7a62a055 50defines the parameters that control the I/O operation.
c6d039a3 51.P
7a62a055 52.in +4n
2be12b9e 53.EX
7a62a055 54#include <linux/aio_abi.h>
fe5dba13 55\&
7a62a055 56struct iocb {
115b4e0e
AC
57 __u64 aio_data;
58 __u32 PADDED(aio_key, aio_rw_flags);
59 __u16 aio_lio_opcode;
60 __s16 aio_reqprio;
61 __u32 aio_fildes;
62 __u64 aio_buf;
63 __u64 aio_nbytes;
64 __s64 aio_offset;
65 __u64 aio_reserved2;
66 __u32 aio_flags;
67 __u32 aio_resfd;
7a62a055 68};
2be12b9e 69.EE
7a62a055 70.in
c6d039a3 71.P
7a62a055
GR
72The fields of this structure are as follows:
73.TP
74.I aio_data
19dc28eb
JM
75This data is copied into the
76.I data
77field of the
78.I io_event
dcd7215c
MK
79structure upon I/O completion (see
80.BR io_getevents (2)).
7a62a055
GR
81.TP
82.I aio_key
a8d5f567 83This is an internal field used by the kernel.
bfddbad0 84Do not modify this field after an
549597a8 85.BR io_submit ()
7a62a055
GR
86call.
87.TP
88.I aio_rw_flags
bfddbad0
MK
89This defines the R/W flags passed with structure.
90The valid values are:
7a62a055
GR
91.RS
92.TP
9d2d82ff
MK
93.BR RWF_APPEND " (since Linux 4.16)"
94.\" commit e1fc742e14e01d84d9693c4aca4ab23da65811fb
95Append data to the end of the file.
e9b96f13
MK
96See the description of the flag of the same name in
97.BR pwritev2 (2)
9d2d82ff
MK
98as well as the description of
99.B O_APPEND
e9b96f13 100in
2be12b9e 101.BR open (2).
9d2d82ff
MK
102The
103.I aio_offset
104field is ignored.
105The file offset is not changed.
7a62a055 106.TP
17ea6db2 107.BR RWF_DSYNC " (since Linux 4.13)"
bfddbad0 108Write operation complete according to requirement of
9d2d82ff 109synchronized I/O data integrity.
e9b96f13
MK
110See the description of the flag of the same name in
111.BR pwritev2 (2)
112as well the description of
9d2d82ff 113.B O_DSYNC
e9b96f13 114in
2be12b9e 115.BR open (2).
7a62a055 116.TP
17ea6db2 117.BR RWF_HIPRI " (since Linux 4.13)"
9d2d82ff
MK
118High priority request, poll if possible
119.TP
2f72816f 120.BR RWF_NOWAIT " (since Linux 4.14)"
bfddbad0
MK
121Don't wait if the I/O will block for operations such as
122file block allocations, dirty page flush, mutex locks,
123or a congested block device inside the kernel.
124If any of these conditions are met, the control block is returned
125immediately with a return value of
2be12b9e
MK
126.B \-EAGAIN
127in the
128.I res
129field of the
130.I io_event
55d59b9b
MK
131structure (see
132.BR io_getevents (2)).
7ac27e31 133.TP
17ea6db2 134.BR RWF_SYNC " (since Linux 4.13)"
9d2d82ff
MK
135Write operation complete according to requirement of
136synchronized I/O file integrity.
7ac27e31
JB
137See the description of the flag of the same name in
138.BR pwritev2 (2)
9d2d82ff
MK
139as well the description of
140.B O_SYNC
7ac27e31
JB
141in
142.BR open (2).
7a62a055
GR
143.RE
144.TP
145.I aio_lio_opcode
8092a5c8
MK
146This defines the type of I/O to be performed by the
147.I iocb
148structure.
bfddbad0 149The
2be12b9e
MK
150valid values are defined by the enum defined in
151.IR linux/aio_abi.h :
152.IP
161b8eda 153.in +4n
2be12b9e 154.EX
7a62a055 155enum {
2be12b9e
MK
156 IOCB_CMD_PREAD = 0,
157 IOCB_CMD_PWRITE = 1,
158 IOCB_CMD_FSYNC = 2,
159 IOCB_CMD_FDSYNC = 3,
af238773 160 IOCB_CMD_POLL = 5,
2be12b9e
MK
161 IOCB_CMD_NOOP = 6,
162 IOCB_CMD_PREADV = 7,
163 IOCB_CMD_PWRITEV = 8,
7a62a055 164};
2be12b9e 165.EE
7a62a055
GR
166.in
167.TP
168.I aio_reqprio
169This defines the requests priority.
170.TP
b085fc1f 171.I aio_fildes
7a62a055
GR
172The file descriptor on which the I/O operation is to be performed.
173.TP
174.I aio_buf
175This is the buffer used to transfer data for a read or write operation.
176.TP
177.I aio_nbytes
178This is the size of the buffer pointed to by
179.IR aio_buf .
180.TP
181.I aio_offset
182This is the file offset at which the I/O operation is to be performed.
183.TP
184.I aio_flags
a1268155
MK
185This is the set of flags associated with the
186.I iocb
187structure.
54028200
AM
188The valid values are:
189.RS
190.TP
1ae6b2c7 191.B IOCB_FLAG_RESFD
54028200 192Asynchronous I/O control must signal the file
7a62a055
GR
193descriptor mentioned in
194.I aio_resfd
195upon completion.
196.TP
54028200
AM
197.BR IOCB_FLAG_IOPRIO " (since Linux 4.18)"
198.\" commit d9a08a9e616beeccdbd0e7262b7225ffdfa49e92
199Interpret the
200.I aio_reqprio
201field as an
202.B IOPRIO_VALUE
203as defined by
a1268155 204.IR linux/ioprio.h .
54028200
AM
205.RE
206.TP
7a62a055
GR
207.I aio_resfd
208The file descriptor to signal in the event of asynchronous I/O completion.
47297adb 209.SH RETURN VALUE
c13182ef 210On success,
60a90ecd 211.BR io_submit ()
a8d55537 212returns the number of \fIiocb\fPs submitted (which may be
ccf7d8ec 213less than \fInr\fP, or 0 if \fInr\fP is zero).
4131356c 214For the failure return, see VERSIONS.
47297adb 215.SH ERRORS
fea681da 216.TP
c4e45390
MK
217.B EAGAIN
218Insufficient resources are available to queue any \fIiocb\fPs.
219.TP
220.B EBADF
221The file descriptor specified in the first \fIiocb\fP is invalid.
222.TP
223.B EFAULT
224One of the data structures points to invalid data.
225.TP
d12c1424 226.B EINVAL
e1c5ebfa 227The AIO context specified by \fIctx_id\fP is invalid.
a8d55537 228\fInr\fP is less than 0.
e1c5ebfa
MK
229The \fIiocb\fP at
230.I *iocbpp[0]
54028200
AM
231is not properly initialized, the operation specified is invalid for the file
232descriptor in the \fIiocb\fP, or the value in the
233.I aio_reqprio
234field is invalid.
fea681da 235.TP
d12c1424 236.B ENOSYS
60a90ecd
MK
237.BR io_submit ()
238is not implemented on this architecture.
54028200
AM
239.TP
240.B EPERM
a1268155
MK
241The
242.I aio_reqprio
243field is set with the class
244.BR IOPRIO_CLASS_RT ,
245but the submitting context does not have the
54028200 246.B CAP_SYS_ADMIN
a1268155 247capability.
47297adb 248.SH VERSIONS
75c018a1 249glibc does not provide a wrapper for this system call.
e1c5ebfa
MK
250You could invoke it using
251.BR syscall (2).
252But instead, you probably want to use the
253.BR io_submit ()
254wrapper function provided by
255.\" http://git.fedorahosted.org/git/?p=libaio.git
256.IR libaio .
c6d039a3 257.P
e1c5ebfa 258Note that the
24d2f49a 259.I libaio
e1c5ebfa
MK
260wrapper function uses a different type
261.RI ( io_context_t )
262.\" But glibc is confused, since <libaio.h> uses 'io_context_t' to declare
263.\" the system call.
264for the
265.I ctx_id
266argument.
267Note also that the
268.I libaio
269wrapper does not follow the usual C library conventions for indicating errors:
24d2f49a
MK
270on error it returns a negated error number
271(the negative of one of the values listed in ERRORS).
272If the system call is invoked via
273.BR syscall (2),
274then the return value follows the usual conventions for
275indicating an error: \-1, with
276.I errno
277set to a (positive) value that indicates the error.
4131356c
AC
278.SH STANDARDS
279Linux.
280.SH HISTORY
281Linux 2.5.
47297adb 282.SH SEE ALSO
c4e45390 283.BR io_cancel (2),
60a90ecd 284.BR io_destroy (2),
364008ba 285.BR io_getevents (2),
ff0c3278
MK
286.BR io_setup (2),
287.BR aio (7)
d12c1424
MK
288.\" .SH AUTHOR
289.\" Kent Yoder.