1IO_SUBMIT(2) Linux Programmer's Manual IO_SUBMIT(2)
2
3
4
6 io_submit - submit asynchronous I/O blocks for processing
7
9 #include <linux/aio_abi.h> /* Defines needed types */
10
11 int io_submit(io_context_t ctx_id, long nr, struct iocb **iocbpp);
12
13 Note: There is no glibc wrapper for this system call; see NOTES.
14
16 The io_submit() system call queues nr I/O request blocks for processing
17 in the AIO context ctx_id. The iocbpp argument should be an array of
18 nr AIO control blocks, which will be submitted to context ctx_id.
19
20 The iocb (I/O control block) structure defined in linux/aio_abi.h
21 defines the parameters that control the I/O operation.
22
23 #include <linux/aio_abi.h>
24
25 struct iocb {
26 __u64 aio_data;
27 __u32 PADDED(aio_key, aio_rw_flags);
28 __u16 aio_lio_opcode;
29 __s16 aio_reqprio;
30 __u32 aio_fildes;
31 __u64 aio_buf;
32 __u64 aio_nbytes;
33 __s64 aio_offset;
34 __u64 aio_reserved2;
35 __u32 aio_flags;
36 __u32 aio_resfd;
37 };
38
39 The fields of this structure are as follows:
40
41 aio_data
42 This data is copied into the data field of the io_event struc‐
43 ture upon I/O completion (see io_getevents(2)).
44
45 aio_key
46 This is an internal field used by the kernel. Do not modify
47 this field after an io_submit() call.
48
49 aio_rw_flags
50 This defines the R/W flags passed with structure. The valid
51 values are:
52
53 RWF_APPEND (since Linux 4.16)
54 Append data to the end of the file. See the description
55 of the flag of the same name in pwritev2(2) as well as
56 the description of O_APPEND in open(2). The aio_offset
57 field is ignored. The file offset is not changed.
58
59 RWF_DSYNC (since Linux 4.13)
60 Write operation complete according to requirement of syn‐
61 chronized I/O data integrity. See the description of the
62 flag of the same name in pwritev2(2) as well the descrip‐
63 tion of O_DSYNC in open(2).
64
65 RWF_HIPRI (since Linux 4.13)
66 High priority request, poll if possible
67
68 RWF_NOWAIT (since Linux 4.14)
69 Don't wait if the I/O will block for operations such as
70 file block allocations, dirty page flush, mutex locks, or
71 a congested block device inside the kernel. If any of
72 these conditions are met, the control block is returned
73 immediately with a return value of -EAGAIN in the res
74 field of the io_event structure (see io_getevents(2)).
75
76 RWF_SYNC (since Linux 4.13)
77 Write operation complete according to requirement of syn‐
78 chronized I/O file integrity. See the description of the
79 flag of the same name in pwritev2(2) as well the descrip‐
80 tion of O_SYNC in open(2).
81
82 aio_lio_opcode
83 This defines the type of I/O to be performed by the iocb struc‐
84 ture. The valid values are defined by the enum defined in
85 linux/aio_abi.h:
86
87 enum {
88 IOCB_CMD_PREAD = 0,
89 IOCB_CMD_PWRITE = 1,
90 IOCB_CMD_FSYNC = 2,
91 IOCB_CMD_FDSYNC = 3,
92 IOCB_CMD_POLL = 5,
93 IOCB_CMD_NOOP = 6,
94 IOCB_CMD_PREADV = 7,
95 IOCB_CMD_PWRITEV = 8,
96 };
97
98 aio_reqprio
99 This defines the requests priority.
100
101 aio_fildes
102 The file descriptor on which the I/O operation is to be per‐
103 formed.
104
105 aio_buf
106 This is the buffer used to transfer data for a read or write
107 operation.
108
109 aio_nbytes
110 This is the size of the buffer pointed to by aio_buf.
111
112 aio_offset
113 This is the file offset at which the I/O operation is to be per‐
114 formed.
115
116 aio_flags
117 This is the set of flags associated with the iocb structure.
118 The valid values are:
119
120 IOCB_FLAG_RESFD
121 Asynchronous I/O control must signal the file descriptor
122 mentioned in aio_resfd upon completion.
123
124 IOCB_FLAG_IOPRIO (since Linux 4.18)
125 Interpret the aio_reqprio field as an IOPRIO_VALUE as
126 defined by linux/ioprio.h.
127
128 aio_resfd
129 The file descriptor to signal in the event of asynchronous I/O
130 completion.
131
133 On success, io_submit() returns the number of iocbs submitted (which
134 may be less than nr, or 0 if nr is zero). For the failure return, see
135 NOTES.
136
138 EAGAIN Insufficient resources are available to queue any iocbs.
139
140 EBADF The file descriptor specified in the first iocb is invalid.
141
142 EFAULT One of the data structures points to invalid data.
143
144 EINVAL The AIO context specified by ctx_id is invalid. nr is less than
145 0. The iocb at *iocbpp[0] is not properly initialized, the
146 operation specified is invalid for the file descriptor in the
147 iocb, or the value in the aio_reqprio field is invalid.
148
149 ENOSYS io_submit() is not implemented on this architecture.
150
151 EPERM The aio_reqprio field is set with the class IOPRIO_CLASS_RT, but
152 the submitting context does not have the CAP_SYS_ADMIN capabil‐
153 ity.
154
156 The asynchronous I/O system calls first appeared in Linux 2.5.
157
159 io_submit() is Linux-specific and should not be used in programs that
160 are intended to be portable.
161
163 Glibc does not provide a wrapper function for this system call. You
164 could invoke it using syscall(2). But instead, you probably want to
165 use the io_submit() wrapper function provided by libaio.
166
167 Note that the libaio wrapper function uses a different type (io_con‐
168 text_t) for the ctx_id argument. Note also that the libaio wrapper
169 does not follow the usual C library conventions for indicating errors:
170 on error it returns a negated error number (the negative of one of the
171 values listed in ERRORS). If the system call is invoked via
172 syscall(2), then the return value follows the usual conventions for
173 indicating an error: -1, with errno set to a (positive) value that
174 indicates the error.
175
177 io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), aio(7)
178
180 This page is part of release 5.07 of the Linux man-pages project. A
181 description of the project, information about reporting bugs, and the
182 latest version of this page, can be found at
183 https://www.kernel.org/doc/man-pages/.
184
185
186
187Linux 2020-04-11 IO_SUBMIT(2)